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)
Mostra commenti meno recenti
??? 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
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])
Risposte (2)
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
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
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.
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
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.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!