MATLAB: Error message in solving symbolic equation??

equationerrorsolve

syms m_c0 j_L0 theta1 M m_c_gama j_L_gama j_L_theta1 m_c_theta2 _L_theta2
syms m_c_theta1 gama l theta2 k1
eqn1=m_c_theta1==(m_c0-1/M+1)*cos(theta1)+j_L0*sin(theta1)+1/M-1;
eqn2=j_L_theta1==(-m_c0+1/M-1)*sin(theta1)+j_L0*cos(theta1);
%eqn3=m_m_theta1==1;
%eqn3=j_Lm_theta1==j_Lm0+l*theta1;
eqn4=m_c_theta2==j_L_theta1*sin(theta2-theta1)+(m_c_theta1+1)*cos(theta2-theta1)-1;
eqn5=j_L_theta2==j_L_theta1*cos(theta2-theta1)-(m_c_theta1+1)*sin(theta2-theta1);
%m_m_theta2=1;
%qn6=j_Lm_theta2==j_Lm0+l*theta2;
eqn7=m_c_gama==(1/k1)*j_L_theta2*sin(k1*(gama-theta2))+m_c_theta2*cos(k1*(gama-theta2));
eqn8=j_L_gama==j_L_theta2*cos(k1*(gama-theta2))-k1*m_c_theta2*sin(k1*(gama-theta2));
%eqn9=j_Lm_gama==j_L_gama;
%m_m_gama=(-m_c_theta2*cos(k1*(gama-theta2))-(1/k1)*j_L_theta2*sin(k1*(gama-theta2)))/(1+l)
m_c_gama=-m_c0;
j_L_gama=-j_L0;
j_L_theta2=(theta2*l)/2;
j_L_gama=j_L_theta2-l*(gama-theta2);
%j_L_theta2=j_Lm_theta2;
%j_Lm0=-j_Lm_gama;
%j_L_gama=j_Lm_gama;
eqns = subs([eqn1, eqn2, eqn4, eqn5, eqn7, eqn8]);
sol = solve(eqns, m_c0, j_L0, m_c_theta1,j_L_theta1,m_c_theta2,j_L_theta2)
this is showing some errors like this:
Error using sym.getEqnsVars>checkVariables (line 92)
The second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 62)
checkVariables(vars);
Error in solve>getEqns (line 450)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 225)
[eqns,vars,options] = getEqns(varargin{:});
Error in eqnsolve_highvolfullload (line 28)
sol = solve(eqns, m_c0, j_L0, m_c_theta1,j_L_theta1,m_c_theta2,j_L_theta2,theta1, theta2)
what should be done?

Best Answer

You defined a value
j_L_theta2=(gama*l)/2;
That makes j_L_theta2 no longer a simple variable. You cannot solve for it in
sol = solve(eqns, m_c0, j_L0, m_c_theta1,j_L_theta1,m_c_theta2,j_L_theta2)
and you need to remove it from the end of the parameter list.
That would leave you with 6 equations and with you requesting to solve only 5 unknowns. There will be no solution to that.
The variables you are not solving for are M, gama, k1, l, theta1, and theta2 . You should add one of those to the solve() parameter list to solve for it. If you add M or l or theta1 to the parameter list then you will get a solution. However if you add gama or k1 or theta2 then no solution will be found.