The way MATLAB executes a code

1 次查看(过去 30 天)
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by