Main Content

le

Define less than or equal to condition

Description

example

A <= B defines the condition less than or equal to.

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

Examples

collapse all

Set the assumption that x is less than or equal to 3 by using assume.

syms x
cond = x <= 3;
assume(cond)

Solve an equation for x. The solver only returns solutions that are valid under the assumption on x.

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

Set the condition abs(sin(x)) <= 1/2.

syms x
cond = abs(sin(x)) <= 1/2;

Find multiples of π/24 that satisfy the condition by using a for loop from 0 to π.

for i = 0:sym(pi/12):sym(pi)
  if subs(cond, x, i)
    disp(i)
  end
end
0
pi/12
pi/6
(5*pi)/6
(11*pi)/12
pi

Input Arguments

collapse all

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

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

Tips

  • Calling <= or le for non-symbolic A and B invokes the MATLAB® le function. This function returns a logical array with elements set to logical 1 (true) where A is less than or equal to B; otherwise, it returns logical 0 (false).

  • 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.

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

Version History

Introduced in R2012a