Getting Started Previous page   Next Page

while

The while loop repeats a group of statements an indefinite number of times under control of a logical condition. A matching end delineates the statements.

Here is a complete program, illustrating while, if, else, and end, that uses interval bisection to find a zero of a polynomial.

The result is a root of the polynomial x3 - 2x - 5, namely

The cautions involving matrix comparisons that are discussed in the section on the if statement also apply to the while statement.


Previous page  for continue Next page

© 1994-2005 The MathWorks, Inc.