1) Given the following MATLAB for loop: for a= 1:6 b=a*3; end What is the value of b upon completion of the loop?
1 次查看(过去 30 天)
显示 更早的评论
1) Given the following MATLAB for loop:
for a= 1:6
b=a*3;
end
What is the value of b upon completion of the loop?
2) Given the following MATLAB for loop:
for a= 1:6
b=a*3;
end
Once the loop has completed, what is the value of a?
1 个评论
James Tursa
2015-3-26
编辑:James Tursa
2015-3-26
Seriously, it would be less effort to simply copy and paste that loop into MATLAB than to create this Question. Just do it and see what the result is.
回答(1 个)
James Tursa
2015-3-26
- Highlight all three lines of the for loop
- Press Ctrl-C
- Click on the MATLAB command window (the one with the >> showing)
- Press Ctrl-V
- Examine the values of a and b
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!