How to solve symbolic system of non linear equation

12 views (last 30 days)
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)
solt1 = 
solt2 = 
solt3 = 

Answers (2)

Torsten
Torsten on 21 Mar 2016
[solt1,solt2,solt3]=solve(eq1,eq2,eq3,t2,t3,t4);
Best wishes
Torsten.
  7 Comments
ves dim
ves dim on 21 Mar 2016
Moved: Walter Roberson on 14 Apr 2025
indeed your script is not working on my computer i check solve documentation and i come back
Walter Roberson
Walter Roberson on 21 Mar 2016
Moved: Walter Roberson on 14 Apr 2025
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.)

Sign in to comment.


rami a.sh
rami a.sh on 20 Apr 2021
Edited: Walter Roberson on 20 Apr 2021
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);
  2 Comments
Ezio Cosatto
Ezio Cosatto on 14 Apr 2025
I've 13 unknowns and 13 equations, but I cannot solve the problem:
syms EBp EF FBp GCp GH HCp IDp IL LDp MAp MN NAp x real;
eqn1 = MAp*NAp/2==x;
eqn2 = NAp*EBp == MAp*FBp;
eqn3 = MAp*EF == MN*EBp;
eqn4 = EF*GCp == EBp*GH;
eqn5 = FBp*GH == EF*HCp;
eqn6 = GH*IDp == GCp*IL;
eqn7 = GH*LDp == HCp*IL;
eqn8 = IL*MAp == IDp*MN;
eqn9 = IL*NAp == LDp*MN;
eqn10 = EBp*FBp == 4;
eqn11 = GCp*HCp == 8;
eqn12 = LDp*IDp == 2;
eqn13 = GCp^2 + HCp^2 == GH^2;
[solu] = solve(eqn1,eqn2,eqn3,eqn4,eqn5,eqn6,eqn7,eqn8,eqn9,eqn10,eqn11,eqn12,eqn13,x)
solu = Empty sym: 0-by-1
Walter Roberson
Walter Roberson on 14 Apr 2025
Edited: Walter Roberson on 14 Apr 2025
What you were requesting to do was find a single variable, x, that solved all 13 equations simultaneously. You need to solve() for as many variables as you have equations.
syms EBp EF FBp GCp GH HCp IDp IL LDp MAp MN NAp x real;
eqn1 = MAp*NAp/2==x;
eqn2 = NAp*EBp == MAp*FBp;
eqn3 = MAp*EF == MN*EBp;
eqn4 = EF*GCp == EBp*GH;
eqn5 = FBp*GH == EF*HCp;
eqn6 = GH*IDp == GCp*IL;
eqn7 = GH*LDp == HCp*IL;
eqn8 = IL*MAp == IDp*MN;
eqn9 = IL*NAp == LDp*MN;
eqn10 = EBp*FBp == 4;
eqn11 = GCp*HCp == 8;
eqn12 = LDp*IDp == 2;
eqn13 = GCp^2 + HCp^2 == GH^2;
[solu] = solve(eqn1,eqn2,eqn3,eqn4,eqn5,eqn6,eqn7,eqn8,eqn9,eqn10,eqn11,eqn12,eqn13)
solu = struct with fields:
EBp: [24x1 sym] EF: [24x1 sym] FBp: [24x1 sym] GCp: [24x1 sym] GH: [24x1 sym] HCp: [24x1 sym] IDp: [24x1 sym] IL: [24x1 sym] LDp: [24x1 sym] MAp: [24x1 sym] MN: [24x1 sym] NAp: [24x1 sym] x: [24x1 sym]
solu.EBp
ans = 
solu.EF
ans = 

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!