필터 지우기
필터 지우기

The way MATLAB executes a code

조회 수: 1 (최근 30일)
Richard
Richard 2012년 1월 17일
Just wondering... suppose I have a code like
a = 1+2+3;
b = 1+3+5;
c = a+b;
fprintf('%2d',c)
What is MATLAB actually doing? Does it evaluate a before reading the line of code for b, or does it skip over the individual calculations until it reaches the print command which asks for a and b to be evaluated?
In other words, if the code is such that
a = 1+2+3;
b = 1+3+5;
fprintf('%2d',b)
would a get evaluated too and stored somewhere?
Thank you.

채택된 답변

the cyclist
the cyclist 2012년 1월 17일
MATLAB is a procedural language. It will calculate and store a and b, regardless of later lines of code "needing" them. In the MATLAB editor, you will see a warning that those variables may be unused.
  댓글 수: 1
Richard
Richard 2012년 1월 17일
Thanks, the cyclist! :-)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by