|MATLAB Function Reference|
Logical operations, with short-circuiting capability
|| are the logical
OR operators used to evaluate logical expressions. Use
|| in the evaluation of compound expressions of the form
expression_2 each evaluate to a scalar logical result.
|| operators support short-circuiting. This means that the second operand is evaluated only when the result is not fully determined by the first operand. See Short-Circuit Operators in the MATLAB documentation for a discussion on short-circuiting with
Always use the |
In the following statement, it doesn't make sense to evaluate the relation on the right if the divisor,
b, is zero. The test on the left is put in to avoid generating a warning under these circumstances:
By definition, if any operands of an
AND expression are
false, the entire expression must be
false. So, if
(b ~= 0) evaluates to
false, MATLAB assumes the entire expression to be
false and terminates its evaluation of the expression early. This avoids the warning that would be generated if MATLAB were to evaluate the operand on the right.
Logical operators, elementwise,
|Logical Operators: Elementwise & | ~||loglog|
© 1994-2005 The MathWorks, Inc.