not

Logical NOT for symbolic expressions

Syntax

~A
not(A)

Description

~A represents the logical negation. ~A is true when A is false and vice versa.

not(A) is equivalent to ~A.

Input Arguments

A

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

Examples

Create this logical expression using ~:

syms x y
xy = ~(x > y);

Use assume to set the corresponding assumption on variables x and y:

assume(xy)

Verify that the assumption is set:

assumptions
ans =
~y < x

Create this logical expression using logical operators ~ and &:

syms x
range = abs(x) < 1 & ~(abs(x) < 1/3);

Replace variable x with these numeric values. Note that subs does not evaluate these inequalities to logical 1 or 0.

x1 = subs(range, x, 0)
x2 = subs(range, x, 2/3)
x1 =
0 < 1 & ~0 < 1/3
x2 =
2/3 < 1 & ~2/3 < 1/3

To evaluate these inequalities to logical 1 or 0, use logical or isAlways:

logical(x1)
isAlways(x2)
ans =
     0

ans =
     1

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 =
FALSE
 
s2 =
TRUE

Convert symbolic TRUE or FALSE to logical values using logical:

logical(s1)
logical(s2)
ans =
     0

ans =
     1

More About

expand all

Tips

  • If you call simplify for a logical expression that contains symbolic subexpressions, you can get symbolic values TRUE or FALSE. These values are not the same as logical 1 (true) and logical 0 (false). To convert symbolic TRUE or FALSE to logical values, use logical.

See Also

| | | | | |

Was this topic helpful?