Y = any(X)
any(X)
, where X
is a vector, returns 1 if any of the elements of X
are nonzero. It returns 0 if all the elements are zero. For matrices, any(X)
operates on the columns of X
, returning a row vector of 1s and 0s.
if
statements
because anif any(A < 0.5)
do something
end
if
wants to respond to a single condition, not a vector of possibly conflicting suggestions. Applying the function twice, as in any(any(A))
, always reduces the matrix to a scalar condition.
&
,|
,~
,all
(c) Copyright 1994 by The MathWorks, Inc.