MATLAB Answers

'break' in 'while' loop

조회 수: 2(최근 30일)
Hi,
I have a 'while' loop inside a 'while' loop.
while
%%%
while
%%%
break
end
%%% statement 1
%%% statement 2
end
I wonder the location of 'break' in this case would break only the inner 'while' loop or break even the outer 'while' loop?
In this case, will it still run 'statement 1' and 'statement 2'?
If not, how do I make sure it only break the inner loop and still run 'statement 1' and 'statement 2'?

  댓글 수: 0

로그인 to comment.

채택된 답변

Fangjun Jiang
Fangjun Jiang 14 Nov 2019
From help break
In nested loops, break exits from the innermost loop only

  댓글 수: 0

로그인 to comment.

More Answers (0)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by