Main Content

not

Logical NOT for symbolic expressions

Syntax

Description

~A represents the logical NOT. ~A is true when A is false and false when A is true.

example

not(A) is equivalent to ~A.

Examples

collapse all

Create a logical condition by using ~.

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

Set the assumption represented by the condition using assume.

assume(cond)

Verify that the assumption is set.

assumptions
ans =
~y < x

Specify a range for x by creating a condition using the logical operators ~ and &.

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

Return the conditions at 0 and 2/3 by substituting for x using subs. The subs function does not evaluate the conditions automatically.

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

Evaluate the inequalities to logical 1 or 0 by using isAlways.

isAlways(x1)
isAlways(x2)
ans =
  logical
     0

ans =
  logical
     1

Input Arguments

collapse all

Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.

Tips

  • If you call simplify for a logical expression containing symbolic subexpressions, you can get the symbolic constants symtrue and symfalse. These two constants are not the same as logical 1 (true) and logical 0 (false). To convert symbolic symtrue and symfalse to logical values, use logical.

Version History

Introduced in R2012a

See Also

| | | | | |