For with Break
1 次查看(过去 30 天)
显示 更早的评论
Hi all.Please Help me.
How I can use for with break. "
for i=1:n;
%action
if H == 1 ; break
end
end
采纳的回答
Teja Muppirala
2011-5-7
Seems like you've got the right idea:
for n=1:100
disp(n)
if n == 7
disp('Hello everybody')
break
end
end
2 个评论
Teja Muppirala
2011-5-7
One more example:
n = 100;
for k=1:n
k
H = k^2;
if H == 36
disp('H is now 36. I will stop')
break
end
end
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!