MATLAB Function Reference
  Go to function:
    Search    Help Desk 
break    Examples   See Also

Terminate execution of a for loop or while loop

Syntax

Description

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

Examples

The example below shows a while loop that reads the contents of the file fft.m into a MATLAB character array. A break statement is used to exit the while loop when the first empty line is encountered. The resulting character array contains the M-file help for the fft program.

See Also

end, for, return, while



[ Previous | Help Desk | Next ]