Determine if all array elements are nonzero or true

Syntax and Description

all(A) tests along the first array dimension of A whose size does not equal 1, and determines if the elements are all nonzero or logical 1 (true). In practice, all is a natural extension of the logical AND operator.
  • If A is a vector, then all(A) returns logical 1 (true) if all the elements are nonzero and returns logical 0 (false) if one or more elements are zero.
  • If A is a nonvector matrix, then all(A) treats the columns of A as vectors and returns a row vector of logical 1s and 0s.
all(A,dim) tests elements along dimension dim. The dim input is a positive integer scalar.

Back to functions