David
Farruggio

MathGenie

any

Determine if any array elements are nonzero

Syntax and Description

any(A) tests along the first array dimension of 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 A is a vector, then B = any(A) returns logical 1 (true) if any of the elements of A is a nonzero number or is logical 1, and returns logical 0 (false) if all the elements are zero.
  • If A is a nonvector matrix, then B = any(A) treats the columns of A as vectors, returning a row vector of logical 1s and 0s.
any(A,dim) tests elements along dimension dim. The dim input is a positive integer scalar.

Back to functions