How to solve an inequality in MATLAB with the <>
operator,
I tried to run the following example (the solution is x=y
or y
):
syms x y;
eqn1 = x^2==y^2;
eqn2 = 3*x<>3*y;
eqn = [eqn1 eqn2];
solve(eqn)
but I get an error. The help doesn't give an answer.
If there's not a built-in solution, how can I specify the values to except for the solve
function
The not equal
operator <>
is defined in Matlab as ~= (docs)
, so you could change your code to:
syms x y;
eqn1 = x^2 == y^2;
eqn2 = 3*x ~= 3*y;
eqn = [eqn1 eqn2];
solve(eqn)