You are on page 1of 6

07.04.

2017

Applications

Symbol Role More Information

& Logical AND and


| Logical OR or
&& Logical AND (with short-
circuiting) Logical Operators: Short-
|| Logical OR (with short- Circuit && ||
circuiting)
~ Logical NOT not

1
07.04.2017

Syntax
DM1 && DM2
DM1 || DM2

Description

DM1 && DM2 represents a logical AND operation that employs short-circuiting behavior.
That is, DM2 is not evaluated if DM1 is logical 0 (false). Each expression must evaluate to a
scalar logical result.

DM1 || DM2 represents a logical OR operation that employs short-circuiting behavior.


That is, DM2 is not evaluated if DM1 is logical 1 (true). Each expression must evaluate to a
scalar logical result.

b = 1;
a = 20;
x = (b ~= 0) && (a/b > 18.5)
x = logical
1

b = 0;
x = (b ~= 0) && (a/b > 18.5)
x = logical
0

2
07.04.2017

X = [1 0 0 1 1];
Y = [0 0 0 0 0];
any(X) || any(Y)
ans = logical
1

3
07.04.2017

4
07.04.2017

5
07.04.2017

You might also like