MATLAB Function Reference |

Execute block of code specified number of times

**Syntax**

**Description**

The columns of the

are stored one at a time in the variable while the following statements, up to the *expression*`end`

, are executed.

In practice, the

is almost always of the form *expression*`scalar`

`:`

`scalar`

, in which case its columns are simply scalars.

The scope of the `for`

statement is always terminated with a matching `end`

.

**Examples**

Assume `k`

has already been assigned a value. Create the Hilbert matrix, using `zeros`

to preallocate the matrix to conserve memory:

Step `s`

with increments of -`0.1`

Successively set `e`

to the unit `n`

-vectors:

**See Also**

`end`

, `while`

, `break`

, `continue`

, `return`

, `if`

, `switch`

, `colon`

fopen | format |

© 1994-2005 The MathWorks, Inc.