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

Find indices and values of nonzero elements

Syntax

Description

k = find(X) returns the indices of the array x that point to nonzero elements. If none is found, find returns an empty matrix.

[i,j] = find(X) returns the row and column indices of the nonzero entries in the matrix X. This is often used with sparse matrices.

[i,j,v] = find(X) returns a column vector v of the nonzero entries in X, as well as row and column indices.

In general, find(X) regards X as X(:), which is the long column vector formed by concatenating the columns of X.

Examples

[i,j,v] = find(X~=0) produces a vector v with all 1s, and returns the row and column indices.

Some operations on a vector

And on a matrix

See Also

nonzeros, sparse

The logical operators &, |, ~

The relational operators <, <=, >, >=, ==, ~=

The colon operator :



[ Previous | Help Desk | Next ]