and

Logical AND for symbolic expressions

Description

example

A & B represents the logical AND. A & B is true only when both A and B are true.

and(A,B) is equivalent to A & B.

Examples

collapse all

Combine symbolic inequalities into one condition by using &.

syms x y
cond = x>=0 & y>=0;

Set the assumptions represented by the condition using assume.

assume(cond)

Verify that the assumptions are set.

assumptions
ans =
[ 0 <= x, 0 <= y]

Define a range for a variable by combining two inequalities into a logical condition using &.

syms x
range = 0 < x & x < 1;

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

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

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

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

Input Arguments

collapse all

Input, specified as a symbolic equation, inequality, or expression.

Input, specified as a symbolic equation, inequality, or expression.

Tips

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

See Also

| | | | | |

Introduced in R2012a