stop for loop if a thing happens

4 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by