Logical OR for symbolic expressions
A  B
or(A,B)
represents
the logical disjunction. A
 B
A  B
is true when either A
or B
or
both are true.

Symbolic equation, inequality, or logical expression that contains symbolic subexpressions. 

Symbolic equation, inequality, or logical expression that contains symbolic subexpressions. 
Combine these symbolic inequalities into the logical expression
using 
:
syms x y xy = x >= 0  y >= 0;
Set the corresponding assumptions on variables x
and y
using assume
:
assume(xy)
Verify that the assumptions are set:
assumptions
ans = 0 <= x  0 <= y
Combine two symbolic inequalities into the logical expression
using 
:
range = x < 1  x > 1;
Replace variable x
with these numeric values.
If you replace x
with 10, one inequality is valid.
If you replace x
with 0, both inequalities are
invalid. Note that subs
does
not evaluate these inequalities to logical 1
or 0
.
x1 = subs(range, x, 10) x2 = subs(range, x, 0)
x1 = 1 < 10  10 < 1 x2 = 0 < 1  1 < 0
To evaluate these inequalities to logical 1
or 0
,
use isAlways
:
isAlways(x1) isAlways(x2)
ans = logical 1 ans = logical 0
Note that simplify
does
not simplify these logical expressions to logical 1
or 0
.
Instead, they return symbolic values TRUE
or FALSE
.
s1 = simplify(x1) s2 = simplify(x2)
s1 = TRUE s2 = FALSE
Convert symbolic TRUE
or FALSE
to
logical values using isAlways
:
isAlways(s1) isAlways(s2)
ans = logical 1 ans = logical 0
Combine multiple conditions by applying or
to
the conditions using the fold
function.
syms x cond = fold(@or, x == 1:10); assume(cond) assumptions
ans = x == 1  x == 2  x == 3  x == 4  x == 5 ... x == 6  x == 7  x == 8  x == 9  x == 10