Skip to content

all

Test whether all elements of an array are nonzero.

B = all(A)
B = all(A, dim)
B = all(A, 'all')

Returns logical true (1) if all elements of A along the operating dimension are 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.

all([1 1 1]) % 1
all([1 0 1]) % 0
all([1 1; 1 0]) % [1 0] per-column
all([1 1; 1 0], 'all') % 0
  • any — Test whether any element of an array is nonzero.
  • sum — Sum elements of an array.

Also categorized under: Range Functions / Math.