FIND

Purpose:

Returns indices of non-zero elements or NA if none found.

Syntax:

FIND(series)

(row, col) = FIND(series)

(row, col, val) = FIND(series)

series

-

A series or array.

Returns:

A series or array.

 

(row, col) = FIND(series) returns the row and column indices of the non-zero elements.

 

(row, col, val) = FIND(series) returns the row and column indices and the non-zero elements of series.

Example:

a = {1, 0, 5};

b = find(a);

c = find(a > 1);

d = a[b];

 

returns the following:

 

b == {1, 3}

c == {3}

d == {1, 5}

Example:

a = {{1, 2, 3}, {4, 5, 2}, {2, 8, 9}}

b = find(a == 2);

c = a[b];

 

b and c return:

 

b == {3, 4, 8}

c == {2, 2, 2}

Example:

The following statement:

 

(r, c) = find(a == 2)

 

returns:

 

r == {3, 1, 2}

c == {1, 2, 3}

Example:

(r, c, v) = find((a>=5)*a)

 

r == {2, 3, 3}

c == {2, 2, 3}

v == {5, 8, 9}

Remarks:

As indicated by the second example, FIND returns the indices of the non-zero elements of array as a single "unraveled" series. These indices can be used to address arrays.

See Also:

DELETE

FINDHANDLE

FINDMAX

FINDMIN

FINDVAL

RAVEL

REMOVE

SERMATCH

UNRAVEL