Checking whether a symbolic expression is an equality or inequality?

I have the following code involving symbolic variables and symbolic equations:
a = sym;
eqn1 = a <= 10;
eqn2 = a == 10;
I would like to check (programmatically) that the symbolic object in eqn1 represents an inequality (less than) and eqn2 represents an equality. Is possible to do so?
Thanks!

 Accepted Answer

char(feval(symengine, 'op', eqn1, 1))
The defined relationship operators are _equal, _unequal, _approx, _less, and _leequal . A>B is rewritten as _less(B,A) and A>=B is rewritten as _leequal(B,A)

2 Comments

Thanks, it works! Small typo: the last argument should be zero.
char(feval(symengine, 'op', eqn1, 0))

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!