'break' in 'while' loop

20 ビュー (過去 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 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