How to solve symbolic system of non linear equation
137 次查看(过去 30 天)
显示 更早的评论
Hi,
I need for a robotic project to solve (symbolic) the following system (express t2,t3,t4 in function of x y z) i've created this script but it's not working at all
syms t2 real;
syms t3 real;
syms t4 real;
syms x;syms y;syms z;
eq1=335*cos(t2)* sin(t3) -77*sin(t2)-260*sin(t2)*sin(t4)+260*cos(t2)*cos(t3)*cos(t4)+85==x;
eq2=335*cos(t3)-260* sin(t3)*cos(t4)==y;
eq3=0-335*sin(t2)* sin(t3) -77*cos(t2) -260*cos(t2)*sin(t4)-260*sin(t2)*cos(t3)*cos(t4) ==z;
[solt1,solt2,solt3]=solve(eq1,eq2,eq3,x,y,z);
0 个评论
回答(5 个)
ves dim
2016-3-21
2 个评论
Torsten
2016-3-21
This simple example works ?
syms u v
eqn1 = 2*u^2 + v^2 == 0;
eqn2 = u - v == 1;
sol = solve(eqn1,eqn2,u,v);
sol.u
sol.v
If not, your MATLAB version is too old for this syntax and you will have to consult the documentation on how to call "solve" for your earlier version.
Best wishes
Torsten.
ves dim
2016-3-21
1 个评论
Torsten
2016-3-21
编辑:Torsten
2016-3-21
But it says: error. That means something with your syntax is incorrect. It does not mean that MATLAB con't find a solution.
So the above simple example works in your case ? If yes, then what's the complete error message if you use
syms x y z t2 t3 t4
eq1 = 335*cos(t2)*sin(t3)-77*sin(t2)-260*sin(t2)*sin(t4)+260*cos(t2)*cos(t3)*cos(t4)+85==x;
eq2 = 335*cos(t3)-260*sin(t3)*cos(t4)==y;
eq3 = -335*sin(t2)*sin(t3)-77*cos(t2)-260*cos(t2)*sin(t4)-260*sin(t2)*cos(t3)*cos(t4)==z;
[solt2,solt3,solt4]=solve(eq1,eq2,eq3,t2,t3,t4);
Best wishes
Torsten.
ves dim
2016-3-21
1 个评论
Walter Roberson
2016-3-21
In older versions of the toolbox, you need to code
A == B
as
(A) - (B)
However, by R2015a the "==" version should be supported, unless you happen to be using Maple for your symbolic engine instead of the Mathworks Symbolic Toolbox (if you did not install Maple then this does not apply to you.)
rami a.sh
2021-4-20
编辑:Walter Roberson
2021-4-20
As explained and written by you , there are 6 unknowns and 3 equations.
This system of equations cant be solved. So , x ,y, and z values should be defined before
as example:
syms t2 t3 t4
x=1;
y=;
z=7;
eq1 = 335*cos(t2)*sin(t3)-77*sin(t2)-260*sin(t2)*sin(t4)+260*cos(t2)*cos(t3)*cos(t4)+85==x;
eq2 = 335*cos(t3)-260*sin(t3)*cos(t4)==y;
eq3 = -335*sin(t2)*sin(t3)-77*cos(t2)-260*cos(t2)*sin(t4)-260*sin(t2)*cos(t3)*cos(t4)==z;
[solt2,solt3,solt4]=solve(eq1,eq2,eq3,t2,t3,t4);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!