Terminate a loop or a Case switch prematurely
MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
break statement is equivalent to the
_break(). The return value is the
void object of type
In nested loops, only the innermost loop is terminated by
break also terminates a statement sequence
Loops are exited prematurely by
for i from 1 to 10 do print(i); if i = 2 then break end_if end_for
all commands starting with the first matching branch are executed:
x := 2: case x of 1 do print(1); x^2; of 2 do print(2); x^2; of 3 do print(3); x^2; otherwise print(UNKNOWN) end_case:
In the next version,
break ensures that only
the statements in the matching branch are evaluated:
case x of 1 do print(1); x^2; break; of 2 do print(2); x^2; break; of 3 do print(3); x^2; break; otherwise print(UNKNOWN) end_case: