sub2ind — matrix subscript values to linear index
I = sub2ind(dims,i1,i2,...) J = sub2ind(dims,Mi)
vector: the matrix dimensions
the subscript value arrays(same matrix shape as
I)
matrix whose columns contains the subscript values.
the linear index array
sub2ind is used to determine the equivalent
single index corresponding to a given set of subscript values. I
= sub2ind(dims,i1,i2,..) returns the linear index equivalent to
the row, column, ... subscripts in the arrays i1,
i2,.. for an matrix of size dims. In
this case i1, i2,.. must have the
same shape and the result I has the same matrix shape.
I = sub2ind(dims,Mi) returns the linear index
equivalent to the subscripts in the columns of the matrix
Mi for a matrix of size dims. in
this case I is a column vector.