ALL All True Function
Section: Elementary Functions
UsageReduces a logical array along a given dimension by testing for all logical 1s. The general syntax for its use is
y = all(x,d)
x is an
n-dimensions array of
The output is of
logical type. The argument
optional, and denotes the dimension along which to operate.
y is the same size as
x, except that it is
singular along the operated direction. So, for example,
x is a
3 x 3 x 4 array, and we
all operation along
d=2, then the output is of size
3 x 1 x 4.
Function InternalsThe output is computed via
d is omitted, then the minimum is taken over all elements of
ExampleThe following piece of code demonstrates various uses of the
--> A = [1,0,0;1,0,0;0,0,1] A = 1 0 0 1 0 0 0 0 1
We start by calling
all without a dimension argument, in which
case it defaults to testing all values of
--> all(A) ans = 0 0 0
all function is useful in expressions also.
--> all(A>=0) ans = 1 1 1
Next, we apply the
all operation along the rows.
--> all(A,2) ans = 0 0 0