MATLAB Answers

0

'break' in 'while' loop

Asked by Salad Box on 14 Nov 2019 at 18:07
Latest activity Answered by Fangjun Jiang
on 14 Nov 2019 at 18:21
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 Comments

Sign in to comment.

1 Answer

Fangjun Jiang
Answer by Fangjun Jiang
on 14 Nov 2019 at 18:21
 Accepted Answer

From help break
In nested loops, break exits from the innermost loop only

  0 Comments

Sign in to comment.