any
Determine if any array elements are nonzero
Description
tests
along the first array dimension of B = any(A)A whose size does not equal 1,
and determines if any element is a nonzero number or logical 1
(true). In practice, any is a natural
extension of the logical OR operator.
If
Ais a vector, thenB = any(A)returns logical1(true) if any of the elements ofAis a nonzero number or is logical1, and returns logical0(false) if all the elements are zero.If
Ais a nonempty, nonvector matrix, thenB = any(A)treats the columns ofAas vectors, returning a row vector of logical1s and0s.If
Ais an empty 0-by-0 matrix,any(A)returns logical0(false).If
Ais a multidimensional array,any(A)acts along the first array dimension whose size does not equal 1 and returns an array of logical values. The size of this dimension becomes1, while the sizes of all other dimensions remain the same.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced before R2006a

![any(A,[1 2]) collapses the pages of a 2-by-3-by-3 array into a 1-by-1-by-3 array.](sum_vecdim.png)