sub2ind
- :
ind =sub2ind(sz, row, col)¶ - :
ind =sub2ind(sz, I1, I2, …, In)¶ Convert subscripts into linear (column-major) indices.
sz is a real vector of at least two elements giving the size of the array. Remaining arguments are real arrays of subscripts; scalars expand to the size of the non-scalar inputs. The result has that size and class double.
When fewer subscripts than dimensions are given, the last subscript addresses the folded trailing dimensions. Extra subscripts beyond the number of dimensions must lie in
1..1.