break

Purpose

Break out of flow control structures.

Synopsis

break

Description

break terminates the execution of for and while loops. In nested loops, break exits from the innermost loop only.

Examples

The indented statements execute until the user enters a nonpositive n.

while 1
    n = input('Enter n. n <= 0 quits. n = ')
    if n <= 0,break,end
    r = rank(magic(n))
end
disp('That''s all.')

See Also

end, error, for, if, return, while

(c) Copyright 1994 by The MathWorks, Inc.