MATLAB Function Reference
  Go to function:
    Search    Help Desk 
sub2ind    Examples   See Also

Single index from subscripts

Syntax

Description

The sub2ind command determines the equivalent single index corresponding to a set of subscript values.

IND = sub2ind(siz,I,J) returns the linear index equivalent to the row and column subscripts in the arrays I and J for an matrix of size siz.

IND = sub2ind(siz,I1,I2,...,In) returns the linear index equivalent to the n subscripts in the arrays I1,I2,...,In for an array of size siz.

Examples

The mapping from subscripts to linear index equivalents for a 2-by-2-by-2 array is:


See Also

ind2sub     Subscripts from linear index

find        Find indices and values of nonzero elements



[ Previous | Help Desk | Next ]