'break' in 'while' loop

조회 수: 22 (최근 30일)
Salad Box
Salad Box 2019년 11월 14일
답변: Fangjun Jiang 2019년 11월 14일
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'?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2019년 11월 14일
From help break
In nested loops, break exits from the innermost loop only

추가 답변 (0개)

카테고리

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