Returns indices of non-zero elements or NA if none found.
FIND(series, first)
(row, col) = FIND(series, first)
(row, col, val) = FIND(series, first)
series |
- |
A series or array. |
first |
- |
Optional. An integer, the find first flag. If 1, return the index of the first non-zero element only. Defaults to 0, find all non-zero elements. |
A series or array.
(row, col) = FIND(series, first)
returns the row and column indices of the
(row, col, val) = FIND(series, first)
returns the row and column indices and the
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}
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}
The following statement:
(r, c) = find(a == 2)
returns:
r == {3, 1, 2}
c == {1, 2, 3}
(r, c, v) = find((a>=5)*a)
r == {2, 3, 3}
c == {2, 2, 3}
v == {5, 8, 9}
W1: gsin(1000, 1/1000, 1)
W2: find(w1 > 0.5)
W3: find(w1 > 0.5, 1)
W2 == 85..417
W3 == {85}
W2 returns the indices of the samples in W1 where the sine wave amplitude exceeds 0.5.
W3 returns the index of the first sample where the amplitude exceeds 0.5.
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.
If first is 1, the index of the first non-zero element is returned, often resulting in faster searches.