find — find indices of boolean vector or matrix true elements
[ii]=find(x [,nmax]) [i1,i2,..]=find(x [,nmax])
may be a boolean vector, a boolean matrix, a boolean hypermatrix, a "standard" matrix or hypermatrix
an integer giving the maximum number of indices to return. The default value is -1 which stands for "all". This option can be used for efficiency, to avoid searching all indices.
integer vectors of indices or empty matrices
If x
is a boolean matrix,
ii=find(x)
returns the vector
of indices i
for which x(i)
is "true". If no true element
found find returns an empty matrix.
[i1,i2,..]=find(x)
returns vectors of indices i1
(for rows) and i2
(for columns),..
such that x(i1(n),i2(n),..)
is "true". If no true element
found find returns empty matrices in i1
,
i2
, ...
if x
is a standard matrix or hypermatrix find(x)
is interpreted as
find(x<>0)
find([])
returns []