Hi, I want to solve 12 equation in 12 unknown but is nonlinear equation for robotic arm ((??? Error using ==> solve>getEqns at 173 ))

4 visualizzazioni (ultimi 30 giorni)
??? Error using ==> solve>getEqns at 173
' s6*(c4*(s2*c1*s3 –c2*c1*c3) + s4*(s2*c1*c3 +c2*c1*s3)) + c6*(s5*(c4*(s2*c1*c3
+c2*c1*s3) - s4*(s2*c1*s3 c2*c1*c3)) -c5*s1)=1 ' is not a valid expression or equation.
Error in ==> solve at 84
[eqns,vars] = getEqns(varargin{:});
Any help you all can provide would be appreciated! Thanks!
  1 Commento
Manuel Fuelling
Manuel Fuelling il 26 Mar 2018
I have a similiar system of equations. Now with 12 unknown and 12 equations. I applied same as Ahmed El Hussieny. Still vpasolve doesnt calculate correctly. Is vpasolve the correct one to use?
syms x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12
F(1) = x1-x3 == 0;
F(2) = -x5+x6 == 0;
F(3) = x7+x9-4 == 0;
F(4) = x11+x12-4 == 0;
F(5) = sqrt((x1-x4)^2+(x2-x5)^2+(x3-x6)^2)-2 == 0;
F(6) = sqrt((x4-x7)^2+(x5-x8)^2+(x5-x9)^2)-2 == 0;
F(7) = sqrt((x7-x10)^2+(x8-x11)^2+(x9-x12)^2)-2 ==
F(8) = sqrt((x10-x1)^2+(x11-x2)^2+(x12-x3)^2)-2 == 0;
F(9)= ( (x4-x1)*(x10-x1)+(x5-x2)*(x11-x2)+(x6-x3)*(x12-x3) ) / ((sqrt((x4)-x1)^2+(x5-x2)^2+(x6-x3)^2)*sqrt((x10-x1)^2+(x10-x2)^2+(x12-x3)^2)) -cosd(90) == 0;
F(10)= ( (x1-x4)*(x7-x4)+(x2-x5)*(x8-x5)+(x3-x6)*(x9-x6) ) / ((sqrt((x1)-x4)^2+(x2-x5)^2+(x3-x6)^2)*sqrt((x7-x4)^2+(x8-x5)^2+(x9-x6)^2)) -cosd(90) == 0;
F(11)= ( (x4-x7)*(x12-x7)+(x5-x8)*(x11-x8)+(x6-x9)*(x12-x9) ) / ((sqrt((x4)-x7)^2+(x5-x8)^2+(x6-x9)^2)*sqrt((x10-x7)^2+(x11-x8)^2+(x12-x9)^2)) -cosd(90) == 0;
F(12)= ( (x7-x10)*(x1-x10)+(x8-x11)*(x2-x11)+(x9-x12)*(x3-x12) ) / ((sqrt((x7-x10)^2+(x8-x11)^2+(x9-x12)^2))*sqrt((x1-x10)^2+(x2-x11)^2+(x3-x12)^2)) -cosd(90) == 0;
[sol_x1,sol_x2,sol_x3,sol_x4,sol_x5,sol_x6,sol_x7,sol_x8,sol_x9,sol_x10,sol_x11,sol_x12]=vpasolve([F(1),F(2),F(3),F(4),F(5),F(6),F(7),F(8),F(9),F(10),F(11),F(12)],[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12])

Accedi per commentare.

Risposte (2)

John D'Errico
John D'Errico il 29 Apr 2016
Modificato: John D'Errico il 29 Apr 2016
That it is nonlinear is not pertinent. Although solve will surely fail to produce a result. Try vpasolve.
The reason for your error is that you need to learn to use tools like solve and vpasolve. Instead of = in those expressions at the ends, you need to use the == operator, like this:
-c5*s1)=1
use
-c5*s1)==1
There is a difference.
Again though, even once you fix the above errors, solve will still surely fail to return any result. In fact, it will probably run forever. Then you will ask another question about why solve does not work here. So use vpasolve, to at least have a chance.
  6 Commenti
John D'Errico
John D'Errico il 1 Mag 2016
In general, unless some of the equations are redundant, then no, you cannot solve 12 equations in 11 unknowns to find a unique solution. This is not a MATLAB issue, but just a fact of mathematics.
Walter Roberson
Walter Roberson il 1 Mag 2016
sin(q1) and cos(q1) are not independent: they are related by the sum of their squares being 1, so knowing sin(q1) tells you +/- cos(q1). You need to add these 5 more constraint equations, which gets you to 17 equations in 11 unknowns, which is something you are not going to solve unless some of the equations are redundant.

Accedi per commentare.


Walter Roberson
Walter Roberson il 29 Apr 2016
In your code, remove all the quotes that make the equations strings, and change the "=" to "==". For example,
f0 = s6*(c4*(s2*c1*s3 c2*c1*c3) + s4*(s2*c1*c3 +c2*c1*s3)) + c6*(s5*(c4*(s2*c1*c3 +c2*c1*s3) - s4*(s2*c1*s3 c2*c1*c3)) -c5*s1) == 1;
  2 Commenti
Ahmed El Hussieny
Ahmed El Hussieny il 30 Apr 2016
Thank you Mr. Walter for replying
l already change my code as you say
syms q1 q2 d3 q4 q5 q6
f(1)= cos(q1)*(cos(q2)*(cos(q4)*cos(q5)* cos(q6)- sin(q4)*sin(q6))- sin(q2)*sin(q5)*cos(q6))-sin(q1)*(sin(q4)*cos(q5)*cos(q6)+ cos(q4)*sin(q6))==0 ;
f(2)= sin(q1)*(cos(q2)*(cos(q4)*cos(q5)* cos(q6)- sin(q4)*sin(q6))+ cos(q2)*sin(q5)*cos(q6))-sin(q1)*(sin(q4)*cos(q5)*cos(q6)+ cos(q4)*sin(q6))==0 ;
f(3)= - sin(q2)*(cos(q4)*cos(q5)*cos(q6)- sin(q4) * sin(q6))- cos(q2)*sin(q5)*cos(q6)-1==0 ;
f(4)= cos(q1)*(-cos(q2)*(cos(q4)*cos(q5)* cos(q6)+ sin(q4)*sin(q6))+ sin(q2)*sin(q5)*cos(q6))-sin(q1)*(-sin(q4)*cos(q5)*sin(q6)+ cos(q4)*cos(q6))==0 ;
f(5)= sin(q1)*(-cos(q2)*(cos(q4)*cos(q5)* cos(q6)+ sin(q4)*sin(q6))+ sin(q2)*sin(q5)*cos(q6))+ cos(q1)*(-sin(q4)*cos(q5)*sin(q6)+ cos(q4)*cos(q6))==0 ;
f(6)= sin(q2)*(cos(q4)*cos(q5)*sin(q6) + sin(q4)*cos(q6))+cos(q2)*sin(q5)*sin(q6) == 0 ;
f(7)= cos(q1)*(cos(q2)*cos(q4)*sin(q5) + sin(q2)*cos(q5))- sin(q1)*sin(q4)*sin(q5) == 0 ;
f(8)= sin(q1)*(cos(q2)*cos(q4)*sin(q5) + sin(q2)*cos(q5))+ cos(q1)*sin(q4)*sin(q5) - 1==0 ;
f(9)= - sin(q2)*cos(q4)*sin(q5)+cos(q2)*cos(q5)==0;
f(10)= cos(q1)*sin(q2)*d3- sin(q1)*0.154 + 0.263*(cos(q1)*cos(q2)*cos(q4)*sin(q5)+ cos(q1)*cos(q5)*sin(q2)- sin(q1)*sin(q4)*sin(q5))+0.154==0;
f(11)= sin(q1)*sin(q2)*d3+ cos(q1)*0.154 + 0.263*(cos(q1)*sin(q4)*sin(q5)+ cos(q2)*cos(q4)*sin(q1)*sin(q5)+ cos(q5)* sin(q1)*sin(q2))-0.753==0 ;
f(12)= cos(q2)*d3 + 0.263*(cos(q2)*cos(q5)- cos(q4)*sin(q2)*sin(q5)) == 0 ;
[sol_q1,sol_q2,sol_d3,sol_q4,sol_q5,sol_q6]= vpasolve([f(1),f(2),f(3),f(4),f(5),f(6),f(7),f(8),f(9),f(10),f(11),f(12)],[q1, q2, d3, q4, q5, q6])
I tray to solve equation by vpasolve but is give me error , please check in code
thank you very much
Walter Roberson
Walter Roberson il 30 Apr 2016
As I indicated above, you are trying to solve 12 equations in 6 unknowns. That isn't going to work unless you do not need all 12 equations.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by