stop for loop if a thing happens

9 ビュー (過去 30 日間)
mohammad
mohammad 2011 年 9 月 8 日
コメント済み: feras almasri 2015 年 4 月 4 日
for example:
for i=1:10
a=i+1
if a>5
exit from loop % *which command do this*
end
end

採用された回答

Jan
Jan 2011 年 9 月 8 日
Or BREAK.
You can find a list of commands concerning FOR loops in the "See also" line of help for. This line is created exactly for such questions.

その他の回答 (2 件)

Wesley Ooms
Wesley Ooms 2011 年 9 月 8 日
the command is 'return' i guess

Wesley Ooms
Wesley Ooms 2011 年 9 月 8 日
i looked it up for you. the command is 'break' :)
  2 件のコメント
Oleg Komarov
Oleg Komarov 2011 年 9 月 8 日
@Weasley: please edit your answers in place of creating new ones.
feras almasri
feras almasri 2015 年 4 月 4 日
plz answer him instead of saying this

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by