Indices as expressions

An index can be any expression that results in a scalar or a vector. The index expression is evaluated first, and the resultant values are truncated to integers. For example, suppose `x = [1;2;3;...;100]`, then:

      =x[1:10:2]        ! displays   1  3  5  7  9
      =x[2.1;2.5;2.9]   ! displays   2  2  2
      y=[2:5]           ! define Y to be   2  3  4  5
      =x[y/2+3]         ! displays   4  4  5  5
      z=[2;3]           ! define Z to be   2  3
      =x[y[z+1]-2]      ! displays   2  3

A variable index always starts at one (`1`).

The `LEN` function returns a scalar value equal to the total length of a vector. The `VLEN` function returns a vector whose nth element is the length of the nth dimension of its argument. `VLEN` of a vector returns a vector of length `1`, while `VLEN` of a matrix returns a vector of length `2`.

Note: The `CLEN` function returns a scalar value equal to the length of a string.

Indices on expressions