and

Elementwise logical operation

and(A, B)

• A and B should have the same sizes.
• The output has the same size as A and B.
• An element of the output is assigned logical 1 if the corresponding elements of A and B are both non-zero, logical 0 if otherwise.
• If one of A and B is scalar, this function compares the scalar with each element of the other argument.
• It gives the same result as A && B and A & B.

Example 1: and(a,b) where a and b have the same sizes.

a=randi(3,3,4)-2
b=randi(3,3,4)-2
and(a,b)

a =
-1.000   1.000  -1.000  -1.000
-1.000   1.000   0.000   0.000
0.000   1.000   0.000   0.000

b =
-1.000   0.000   0.000   1.000
1.000   0.000  -1.000   0.000
0.000   0.000  -1.000   1.000

ans =
1  0  0  1
1  0  0  0
0  0  0  0