Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Determine if all array elements are nonzero or `true`

`B = all(A)`

`B = all(A,dim)`

tests
along the first array dimension of `B`

= all(`A`

)`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 nonempty, nonvector matrix, then`all(A)`

treats the columns of`A`

as vectors and returns a row vector of logical`1`

s and`0`

s.If

`A`

is an empty 0-by-0 matrix, then`all(A)`

returns logical`1`

(`true`

).If

`A`

is a multidimensional array, then`all(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 becomes`1`

, while the sizes of all other dimensions remain the same.

Was this topic helpful?