:

Range operator.

Syntax

from : to : step

Operands

from
The starting point of the range (scalar expression only).
to
The end point of the range (scalar expression only).
step
The increment (scalar expression only).

Example

Expression Result
1 : 5 : 1 {1, 2, 3, 4, 5}
1 : 2 : 3 1
2 : -7 : -3 {2, -1, -4, -7}

Comments

The range operator creates a vector or scalar with first element from and incrementing by step until to is reached.

If from + step is greater than to, the result is a scalar. If from + step is less than or equal to to, the result is a vector. The number of points in the result is the greatest integer less than or equal to ((to - from)/step) + 1. The quantity (to - from)/step must be positive and step must be nonzero.