MATLAB Function Reference    
ind2sub

Subscripts from linear index

Syntax

Description

The ind2sub command determines the equivalent subscript values corresponding to a single index into an array.

[I,J] = ind2sub(siz,IND) returns the arrays I and J containing the equivalent row and column subscripts corresponding to the index matrix IND for a matrix of size siz.

For matrices, [I,J] = ind2sub(size(A),find(A>5)) returns the same values as
[I,J] = find(A>5).

[I1,I2,I3,...,In] = ind2sub(siz,IND) returns n subscript arrays I1,I2,..,In containing the equivalent multidimensional array subscripts equivalent to IND for an array of size siz.

Examples

The mapping from linear indexes to subscript equivalents for a 2-by-2-by-2 array is:

See Also

sub2ind, find


 ind2rgb Inf