How to exit from loop function ?
古いコメントを表示
Hi, I need to exit from a loop,should i use break ?
here is an example :
for j=1:10
if (condition 1)
a=5; % example
% continue step
elseif (condition 2)
a=2;
% continue
elseif (condition 3)
a=0;
% !!! reject step
break; % !!
end
What I do ?
Thanks.
6 件のコメント
Jan
2021 年 5 月 1 日
The question is not clear yet. What does "rejecting a step" mean?
Yamina chbak
2021 年 5 月 1 日
Jan
2021 年 5 月 1 日
Yes, and you do this already with the break command. So the code does already what you are asking for,
Yamina chbak
2021 年 5 月 1 日
Image Analyst
2021 年 5 月 1 日
Yamina chbak
2021 年 5 月 1 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および 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!