According to the documentation, the
definition of any :
any (x) ... determines if any element is a nonzero number or a logical 1 (true)
In practice, it anyis a natural extension of the logical operator OR.
If A is an empty 0-by-0 matrix, any(A)returns a logical 0 (false).
and definition of all :
all (x) ... determines whether all elements are nonzero or logical 1 (true)
In practice, it allis a natural extension of the logical AND operator.
A - 0--0, all(A) 1 (true).
:
function out = Any(V)
out = false;
for k = 1:numel(V)
out = out || (~isnan(V(k)) && V(k) ~= 0);
end
end
function out = All(V)
out = true;
for k = 1:numel(V)
out = out && (V(k) ~= 0);
end
end
:
-In any , [ ], , , false.
- any OR, ||
- nonzero , V(k) ~= 0
- numbers, NaN - Not a Number, ~isnan(V(k)).
-In all , [ ], , , true
- all AND, &&
- V(k) ~= 0
- all , ~isnan(V(k))