any
Test whether any element of an array is nonzero.
Syntax
Section titled “Syntax”B = any(A)B = any(A, dim)B = any(A, 'all')Description
Section titled “Description”Returns logical true (1) if any element of A along the operating dimension is nonzero (or true), false (0) otherwise. With no dimension argument, operates along the first non-singleton dimension. With 'all', reduces every element to a single scalar.
For matrices, any(A) produces a row vector of column-wise any results. NaN counts as nonzero.
Examples
Section titled “Examples”any([0 0 0]) % 0any([0 1 0]) % 1any([0 0; 0 1]) % [0 1] per-columnany([0 0; 0 1], 'all') % 1See also
Section titled “See also”Also categorized under: Range Functions / Math.