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);

回答(5 个)

Torsten
Torsten 2016-3-21
[solt1,solt2,solt3]=solve(eq1,eq2,eq3,t2,t3,t4);
Best wishes
Torsten.

ves dim
ves dim 2016-3-21
thanks torsten but there is an error message : error in solve (line8)
  2 个评论
Torsten
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
ves dim 2016-3-21
I have a 2015 version matlab. But I think the problem is more complex than your example indeed my system is a non linear system, and i think that there is a specific way to write it in matlab
  1 个评论
Torsten
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
ves dim 2016-3-21
indeed your script is not working on my computer i check solve documentation and i come back
  1 个评论
Walter Roberson
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
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);

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by