all
Returns a logical that indicates whether all of the corresponding elements of the input are nonzero.
Syntax
R = all(x)
R = all(x,dim)
Inputs
- x
- scalar | complex | vector | matrix
- dim
- The dimension on which to operate
Outputs
- R
- scalar | vector | matrix
Examples
Vector
input:
R = all([1,1,1,0])
R = 0
Matrix
input:
R = all([1,0,1;1,0,0;1,1,1])
R = [ 1 0 0 ]
Matrix input with
dim:
R = all([1,0,1;1,0,0;1,1,1], 2)
R = [ 0; 0; 1 ]
Comments
If a matrix is entered, returns a row vector of logicals with each element indicating whether all of the elements of the corresponding column of the matrix are nonzero. If dim is input all works along the dimension. The default value for dim is 1.