Main Content
sub2ind
Convert subscripts to linear indices
Description
returns the linear indices ind
= sub2ind(sz
,I1,I2,...,In
)ind
corresponding to multidimensional
subscripts in n
arrays I1,I2,...,In
for a
multidimensional array of size sz
. Here sz
is a
vector with n
elements that specifies the size of each array
dimension.
Examples
Input Arguments
Output Arguments
Algorithms
For an array A
, if ind = sub2ind(size(A),I1,…,In)
,
then A(ind(k)) = A(I1(k),…,In(k))
for all k
.