# for

For loop is useful for executing many iterations of a statement.

## Syntax

for X = expression
statement
end

## Inputs

x
Anything that can be logically tested.
Type: double | char | logical | struct | cell | integer
Dimension: scalar | vector | matrix

## Outputs

statement
Executed if the expression in the for condition is true.

## Example

Simple for loop.

sum=0
for j=1:10
sum = sum + j
end
sum
sum = 0
sum = 1
sum = 3
sum = 6
sum = 10
sum = 15
sum = 21
sum = 28
sum = 36
sum = 45
sum = 55
sum = 55