The & operator is an elementwise operator. Just like the + operator will add corresponding elements of its inputs when given two vectors of the same size:
x = [1 2 3];
y = [4 5 6];
z = x + y
The & operator will take the and of the corresponding elements of its inputs.
a = [true false true];
b = [true true false];
c = a & b;
The & operator with two scalars as input returns true if both its inputs are non-zero and false otherwise.
[ true & true; ...
true & false; ...
false & true; ...
false & false]
Best Answer