How to break a for loop but then continue with the rest of code
9 ビュー (過去 30 日間)
古いコメントを表示
Hi I have this situation and I have done coding but my code don't break when all nodes get data.
Can you guide me.

0 件のコメント
採用された回答
Jos (10584)
2016 年 2 月 18 日
Use break
for k=1:100,
if rand < 0.2
disp('Break out of for loop')
break
end
end
disp(k) % almost never reached 100
その他の回答 (1 件)
Fangjun Jiang
2016 年 2 月 18 日
編集済み: Fangjun Jiang
2016 年 2 月 18 日
Use continue or break to control the for-loop.
help continue
help break
参考
カテゴリ
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!