Documentation Center

  • Trial Software
  • Product Updates

le

Define less than or equal to relation

Syntax

A <= B
le(A,B)

Description

A <= B creates a less than or equal to relation.

le(A,B) is equivalent to A <= B.

Input Arguments

A

Number (integer, rational, floating-point, complex, or symbolic), symbolic variable or expression, or array of numbers, symbolic variables or expressions.

B

Number (integer, rational, floating-point, complex, or symbolic), symbolic variable or expression, or array of numbers, symbolic variables or expressions.

Examples

Use assume and the relational operator <= to set the assumption that x is less than or equal to 3:

syms x
assume(x <= 3)

Solve this equation. The solver takes into account the assumption on variable x, and therefore returns these three solutions.

solve((x - 1)*(x - 2)*(x - 3)*(x - 4) == 0, x)
ans =
 1
 2
 3
 

Use the relational operator <= to set this condition on variable x:

syms x
cond = (abs(sin(x)) <= 1/2);
for i = 0:sym(pi/12):sym(pi)
  if subs(cond, x, i)
    disp(i)
  end
end

Use the for loop with step π/24 to find angles from 0 to π that satisfy that condition:

0
pi/12
pi/6
(5*pi)/6
(11*pi)/12
pi

Alternatives

You can also define this relation by combining an equation and a less than relation. Thus, A <= B is equivalent to (A < B) & (A == B).

More About

expand all

Tips

  • If A and B are both numbers, then A <= B compares A and B and returns logical 1 (true) or logical 0 (false). Otherwise, A <= B returns a symbolic less than or equal to relation. You can use that relation as an argument for such functions as assume, assumeAlso, and subs.

  • If both A and B are arrays, then these arrays must have the same dimensions. A <= B returns an array of relations A(i,j,...)<=B(i,j,...)

  • If one input is scalar and the other an array, then the scalar input is expanded into an array of the same dimensions as the other array. In other words, if A is a variable (for example, x), and B is an m-by-n matrix, then A is expanded into m-by-n matrix of elements, each set to x.

  • The field of complex numbers is not an ordered field. MATLAB® projects complex numbers in relations to a real axis. For example, x <= i becomes x <= 0, and x <= 3 + 2*i becomes x <= 3.

See Also

| | | | | |

Was this topic helpful?