error message in solving symbolic equation???

6 views (last 30 days)
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
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)
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?
Manuela Gräfe
Manuela Gräfe on 25 Apr 2017
Hello, umme mumtahina.
I wrote comments under many of your question. Please provide the final solutions! Don't just write "got it!!!". This is a public community and some other people are also interested in the final solutions!
Please contact me via personal message! Click my profile and then send me a message please.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 17 Feb 2017
You defined a value
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.
Walter Roberson
Walter Roberson on 22 Mar 2017
syms m_c0 j_L0 theta1 M m_c_gama j_L_gama j_L_theta1 m_c_theta2 j_L_theta2
syms m_c_theta1 gama l theta2 k1
eqn1L = m_c_theta1;
eqn1R = (m_c0-1/M+1)*cos(theta1)+j_L0*sin(theta1)+1/M-1;
eqn1 = eqn1L - eqn1R;
eqn2L = j_L_theta1;
eqn2R = (-m_c0+1/M-1)*sin(theta1)+j_L0*cos(theta1);
eqn2 = eqn2L - eqn2R;
eqn4L = m_c_theta2;
eqn4R = j_L_theta1*sin(theta2-theta1)+(m_c_theta1+1)*cos(theta2-theta1)-1;
eqn4 = eqn4L - eqn4L;
eqn5L = j_L_theta2;
eqn5R = j_L_theta1*cos(theta2-theta1)-(m_c_theta1+1)*sin(theta2-theta1);
eqn5 = eqn5L - eqn5R;
eqn7L = m_c_gama;
eqn7R = (1/k1)*j_L_theta2*sin(k1*(gama-theta2))+m_c_theta2*cos(k1*(gama-theta2));
eqn7 = eqn7L - eqn7R;
eqn8L = j_L_gama;
eqn8R = j_L_theta2*cos(k1*(gama-theta2))-k1*m_c_theta2*sin(k1*(gama-theta2));
eqn8 = eqn8L - eqn8R;
m_c_gama = -m_c0;
j_L_gama = -j_L0;
j_L_theta2 = (gama*l)/2;
residue = eqn1.^2 + eqn2.^2 + eqn4.^2 + eqn5.^2 + eqn7.^2 + eqn8.^2;
eqn = simplify( subs(residue) );
vars = [M, gama, j_L0, j_L_theta1, k1, l, m_c0, m_c_theta1, m_c_theta2, theta1, theta2];
Fvec = matlabFunction(eqn, 'vars', {vars});
Farray = matlabFunction(eqn, 'vars', vars);
Now you can use Fvec or Farray with a minimizer, looking for values near 0 (which indicate that all of the individual equations are balanced.)
The best I have found so far is
[ M, gama, j_L0, j_L_theta1, k1, l, m_c0, m_c_theta1, m_c_theta2, theta1, theta2] =
[0.264651987992054916, 2.2050144528762562e-17, 2.27231700419163755e-17, 1.74881407157095661e-17, -2.60182412177158895, 1.46780465953763239, 2.99999999999965894, 2.99999999999965894, -2.99999999999965894, 2.36395222838333151e-17, 2.39658891354045945e-17]
with a residue of 7.20318529637006345e-46 -- which is well into numeric noise level.
The search range I used for the above best value was
lowerbound [-1 -eps -eps -eps -3 -3 -3 -3 -3 0 0]
upperbound [ 1 eps eps eps 3 3 3 3 3 2*pi 2*pi]
The -1 to +1, and -3 to +3 were arbitrary restrictions because I could see from my graphics that there was a wide range of values for which they generated very low residues, indicating that the exact range of those values barely mattered. The 0 to +2*pi are for theta1 and theta2, known to be angles. The -eps to +eps were effective 0s for variables that I could see from my graphics had very low residues at values arbitrarily close to 0 -- though it turns out that m_c0 being just a little less than 3.0 is important for the very low residue with the other combination of values.
M of exactly 0 leads to NaN, as does k1 of exactly 0.

Sign in to comment.

More Answers (0)


Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!