and, &
Find logical AND
Description
performs a logical
AND of inputs A
& B
A
and B
and returns an array or
a table containing elements set to either logical 1
(true
) or logical 0
(false
). An element of the output is set to logical
1
(true
) if both A
and
B
contain a nonzero element at that same location. Otherwise,
the element is set to 0
.
For bit-wise logical AND operations, see bitand
.
Examples
Input Arguments
Tips
You can chain together several logical operations, for example,
A & B | C
.The symbols
&
and&&
perform different operations in MATLAB®. The element-wise AND operator described here is&
. The short-circuit AND operator is&&
.When you use the element-wise
&
and|
operators in the context of anif
orwhile
loop expression (and only in that context), they use short-circuiting to evaluate expressions. Otherwise, you must specify&&
or||
to opt-in to short-circuiting behavior. SeeShort-Circuit AND
andShort-Circuit OR
for more information.