sub2ind
Convert subscripts to linear indices
Description
returns the linear indicesind
= sub2ind (sz
,I1,I2,...,In
)ind
corresponding to multidimensional subscripts inn
arraysI1,I2,...,In
for a multidimensional array of sizesz
. Heresz
is a vector withn
elements that specifies the size of each array dimension.
Examples
Input Arguments
Output Arguments
Algorithms
For an arrayA
, ifind = sub2ind(size(A),I1,…,In)
, thenA(ind(k)) = A(I1(k),…,In(k))
for allk
.