Info
此问题已关闭。 请重新打开它进行编辑或回答。
Simple question loop for
1 次查看(过去 30 天)
显示 更早的评论
Hello,
It's a very basic question because I'm new in the world of Matlab.
I want to know what happend when there is a for loop like this :
for i = 1:n
% Inside of the loop
end
but n = 0
Does it enter the loop or not at all ?
Thank you,
Laurie
0 个评论
回答(2 个)
Asad (Mehrzad) Khoddam
2020-10-19
You can simply add a disp command to see that nothing will be printed when n=0. It means that the statements inside the loop will not be executed.
n=0;
for i = 1:n
% test
disp(i);
% Inside of the loop
end
1 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!