Why is the lhs function, including the example posted in the MathWorks documentation, not working?
1 view (last 30 days)
Show older comments
Eric McCormick
on 8 Jan 2019
Commented: Walter Roberson
on 25 Jan 2019
As per the first example documentation posted here, the following code does not work correctly for me:
syms x y
eqn = 2*y == x^2;
lhsEqn = lhs(eqn)
Which should result in:
lhsEqn =
2*y
but, instead gives the following error message:
Undefined function 'lhs' for input arguments of type 'logical'.
Error in test (line 3)
lhsEqn = lhs(eqn);
I have tried various rearrengements of the provided example, but all have been unsucessful.
Thanks for any help which you can provide.
3 Comments
Accepted Answer
Star Strider
on 8 Jan 2019
Apparentlly, MATLAB can’t find the Symbolic Math Toolbox.
First, run these from your Command Window or a script:
restoredefaultpath
rehash toolboxcache
If you still have problems after that, click on the Contact Us link in the top right corner of this page, and request Technical Support.
2 Comments
More Answers (1)
madhan ravi
on 8 Jan 2019
Edited: madhan ravi
on 8 Jan 2019
Might happen in the case that x and y are numeric values hanging in the workspace/global workspace so add clear all/clear global at the beginning and try again:
clear all
clear global
syms x y % requires symbolic math toolbox
eqn = 2*y == x^2;
lhsEqn = lhs(eqn)
To check if you have symbolic math toolbox and license try the below in command window:
ver % symbolic math toolbox should be visible
license('test','symbolic_toolbox') % should return 1
which lhs -all % what does it show?
which rhs -all
5 Comments
Walter Roberson
on 25 Jan 2019
In sufficiently old MATLAB, == between two symbolic expressions immediately returned a logical result that indicated whether the two expressions evaluated to the same internal representation. On those versions, == did not even attempt simplification, and was totally unable to prove anything -- and there was also the risk that logically identical expressions written in different order might not come out the same. a + b + c was not certain to == b + c + a for example.
On the other hand, on versions that old, lhs() did not exist yet -- lhs() was not added to MATLAB until several releases after == started being a useful symbolic operation.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!