Short answer
- When A and B are scalars , use
&&
- When A and B are vectors , use
&
Long answer
-When you use A && B
, it evaluates A
, if A
is zero, then it does not evaluate B
, because no matter what B
, the answer is 0.
-However, when A
and B
are vectors: firstly, using &&
causes an error . Secondly, &
will use some fast CPU instruction set to compute multiple operations at the same time. Third, in this situation, Matlab cannot use the previous lazy estimate &
, because it does not know how to evaluate only a subset of B
source share