breaking a function in matlab
In nested loops, break exits from the innermost loop only. Remarks. If you use break outside of a for or while loop in a MATLAB script or function, break terminates the script or function at that point. If break is executed in an if, switch-case, or try-catch statement, it terminates the statement at that point. Examples.