| MATLAB Function Reference | Search  Help Desk |
| while | Examples See Also |
Repeat statements an indefinite number of times
Syntax
whileexpressionstatementsend
Description
while
repeats statements an indefinite number of times. The statements are executed while the real part of expression has all nonzero elements.expression is usually of the form
whereexpressionropexpression
rop is ==, <, >, <=, >=, or ~=.
The scope of a while statement is always terminated with a matching end.
Examples
The variableeps is a tolerance used to determine such things as near singularity and rank. Its initial value is the machine epsilon, the distance from 1.0 to the next largest floating-point number on your machine. Its calculation demonstrates while loops:
eps = 1;
while (1+eps) > 1
eps = eps/2;
end
eps = eps*2
See Also
all, any, break, end, for, if, return, switch