Why is the lhs function, including the example posted in the MathWorks documentation, not working?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Star Strider
2019 年 1 月 8 日
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 件のコメント
その他の回答 (1 件)
madhan ravi
2019 年 1 月 8 日
編集済み: madhan ravi
2019 年 1 月 8 日
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 件のコメント
Walter Roberson
2019 年 1 月 25 日
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!