Q&A
Ask and answer questions to make information more available to wider audiences.
Robert Gearhart @robert_gearhart   18, Aug 2023 12:00 AM
the & and && logical operators
What is the difference between the & and && logical operators in MATLAB?
answers 1
 
Answer 1
Chance Boorman @boormanchance   31, Aug 2023 10:36 AM
   The single ampersand & is the logical AND operator and it can operate on arrays in an element-wise fashion. A & B means that A and B are evaluated.
    The double ampersand && is again a logical AND operator that employs short-circuiting behavior. Short-circuiting just means the second operand (right-hand side) is evaluated only when the result is not fully determined by the first operand (left-hand side). In other words, A && B means that B is only evaluated if A is true. These can only operate on scalars, not arrays.