Asked by Ahmed El Hussieny
on 29 Apr 2016

??? 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!

Answer by John D'Errico
on 29 Apr 2016

Edited by John D'Errico
on 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.

Ahmed El Hussieny
on 1 May 2016

Mr. Walter if you want to determine the actual angle you must know the sin , cos for this angle, after that, calculate inverse tan to know this angle in any quarter.

Ok, anyway i can describe sin(q1) by symbol s1 and cos(q1) by symbol c1, then for each angle we have 2 unknowns (( c1,s1,c2,s2,c4,s4.....etc)). In the primary equation i have 5 angels and one displacement i can extend 5 angles by the last method to 10 unknowns then total unknowns in 12 equations are 11 in number. Can Matlab solve 12 eq. in 11 unknowns ?!!!!!!

Thank you for caring

John D'Errico
on 1 May 2016

Walter Roberson
on 1 May 2016

Sign in to comment.

Answer by Walter Roberson
on 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;

Ahmed El Hussieny
on 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
on 30 Apr 2016

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Manuel Fuelling (view profile)

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/281734-hi-i-want-to-solve-12-equation-in-12-unknown-but-is-nonlinear-equation-for-robotic-arm-error#comment_549655

Sign in to comment.