An array can be subscripted by a subscript-triplet (a shorthand notation for a linear function) which will give rise to a sub-array of the original. The general form is:
[bound1
]:[
bound2
][:
stride
]
the section starts at bound1
and ends at or before
bound2
.
stride
is the increment by which the locations are selected.
bound1
,
bound2
and
stride
must all be scalar integer
expressions. Thus
A(m:m) = 0 ! m to m 1 elt array A(m:n:k) = 0 ! m to n step k A(8:3:-1) = 0 ! 8 to 3 backwards A(8:3) = 2 ! step 1 => Zero size A(M::4) = 1 ! default UPB, step 4 A(::2) = 1.0 ! default LWB and UPB A(m**2:n*k/3) = 1.0are all valid.
For more information, click here