stop for loop if a thing happens

조회 수: 1 (최근 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 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