error message in solving symbolic equation???

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?

4 件のコメント

Walter Roberson
Walter Roberson 2017 年 4 月 24 日
User removed original code. It looked like,
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
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);
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);
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));
m_c_gama=-m_c0;
j_L_gama=-j_L0;
j_L_theta2=(gama*l)/2;
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)
safi58
safi58 2017 年 4 月 25 日
Sorry Walter, my daughter was playing with the computer and you know what happened then.
Manuela Gräfe
Manuela Gräfe 2017 年 4 月 25 日
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.
Rena Berman
Rena Berman 2017 年 4 月 28 日
(Answers Dev) Restored edit

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2017 年 2 月 17 日

0 投票

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.

22 件のコメント

safi58
safi58 2017 年 2 月 20 日
Is there any chance of getting a solution of theta2?
Walter Roberson
Walter Roberson 2017 年 2 月 20 日
Isolating out the first five variables is quick. Isolating out the theta2 from the remaining (substituted) equation is somewhere between "quite time consuming" and "not possible"; I am not sure yet which. It is too complex for MATLAB to do directly.
Walter Roberson
Walter Roberson 2017 年 2 月 20 日
If I drop in a small number of random constants, theta2 comes out as arctan() of expressions that depend upon the roots of a 12th degree polynomial. As trig equations are involved, it is possible that a completely different equation would fall out for different constants; I am continuing to look.
safi58
safi58 2017 年 3 月 14 日
I also could not find the solution for theta2. I have found the solution for m_c0, j_L0, m_c_theta1,j_L_theta1,m_c_theta2,theta1. But the issue is I am getting square root for some of these values which will give imaginary values at some point. Is there any way to resolve this issue?
Walter Roberson
Walter Roberson 2017 年 3 月 14 日
Could you remind me whether all of the symbols are intended to be real-valued? Or which ones might be complex?
safi58
safi58 2017 年 3 月 14 日
Actually these values are the initial conditions of waveforms such as m_c0, m_c_theta1,m_c_theta2,theta1 are the values for capacitor voltage so these should be real valued.
Walter Roberson
Walter Roberson 2017 年 3 月 14 日
"But the issue is I am getting square root for some of these values which will give imaginary values at some point. Is there any way to resolve this issue?"
You can isolate the first 5 variables without ^2 or sqrt() by making use of the trig identity sin^2 + cos^2 = 1.
But it does not look promising so far for isolating theta1 without sqrt()... I am testing further.
safi58
safi58 2017 年 3 月 14 日
please let me know
Walter Roberson
Walter Roberson 2017 年 3 月 14 日
I killed the calculation after several hours... It was using all of my memory.
safi58
safi58 2017 年 3 月 15 日
How did you do that? I can try on my computer. Do you think that the solution for those variables are correct?
Walter Roberson
Walter Roberson 2017 年 3 月 15 日
About the best I can reduce theta1 down to is a pair of solutions,
arctan( (signum(cos(k1 * (gama - theta2)) + cos(theta2)) * (sin(k1 * (gama - theta2)) * k1 - sin(theta2)) * (( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2) + (cos(k1 * (gama - theta2)) + cos(theta2)) * ( - 2 * M * k1 * (l * gama * cos(theta2) + sin(theta2)) * cos(k1 * (gama - theta2)) + ( - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * sin(k1 * (gama - theta2)) - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1)) / (((k1^2 - 1) * cos(k1 * (gama - theta2))^2 - 2 * cos(k1 * (gama - theta2)) * cos(theta2) + 2 * sin(k1 * (gama - theta2)) * sin(theta2) * k1 - k1^2 - 1) * k1), ( - signum(cos(k1 * (gama - theta2)) + cos(theta2)) * (cos(k1 * (gama - theta2)) + cos(theta2)) * (( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2) - ( - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1 * cos(k1 * (gama - theta2))^2 - 2 * M * (k1 * (l * gama * cos(theta2) + sin(theta2)) * sin(k1 * (gama - theta2)) - l * gama * cos(theta2) * sin(theta2) + cos(theta2)^2 - 1) * k1 * cos(k1 * (gama - theta2)) + (M * l * gama * (k1^2 + 1) * cos(theta2)^2 + 2 * M * cos(theta2) * k1^2 * sin(theta2) - 4 * k1^2 * (M - 1) * sin(theta2) - 3 * (k1^2 + 1/3) * gama * M * l) * sin(k1 * (gama - theta2)) + (( - 2 * M + 2) * cos(theta2)^2 - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * (k1^2 + 1) * (M - 1)) * k1) / (((k1^2 - 1) * cos(k1 * (gama - theta2))^2 - 2 * cos(k1 * (gama - theta2)) * cos(theta2) + 2 * sin(k1 * (gama - theta2)) * sin(theta2) * k1 - k1^2 - 1) * k1))
and
arctan(( - signum(cos(k1 * (gama - theta2)) + cos(theta2)) * (sin(k1 * (gama - theta2)) * k1 - sin(theta2)) * (( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2) + (cos(k1 * (gama - theta2)) + cos(theta2)) * ( - 2 * M * k1 * (l * gama * cos(theta2) + sin(theta2)) * cos(k1 * (gama - theta2)) + ( - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * sin(k1 * (gama - theta2)) - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1)) / (((k1^2 - 1) * cos(k1 * (gama - theta2))^2 - 2 * cos(k1 * (gama - theta2)) * cos(theta2) + 2 * sin(k1 * (gama - theta2)) * sin(theta2) * k1 - k1^2 - 1) * k1), (signum(cos(k1 * (gama - theta2)) + cos(theta2)) * (cos(k1 * (gama - theta2)) + cos(theta2)) * (( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2) - ( - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1 * cos(k1 * (gama - theta2))^2 - 2 * M * (k1 * (l * gama * cos(theta2) + sin(theta2)) * sin(k1 * (gama - theta2)) - l * gama * cos(theta2) * sin(theta2) + cos(theta2)^2 - 1) * k1 * cos(k1 * (gama - theta2)) + (M * l * gama * (k1^2 + 1) * cos(theta2)^2 + 2 * M * cos(theta2) * k1^2 * sin(theta2) - 4 * k1^2 * (M - 1) * sin(theta2) - 3 * (k1^2 + 1/3) * gama * M * l) * sin(k1 * (gama - theta2)) + (( - 2 * M + 2) * cos(theta2)^2 - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * (k1^2 + 1) * (M - 1)) * k1) / (((k1^2 - 1) * cos(k1 * (gama - theta2))^2 - 2 * cos(k1 * (gama - theta2)) * cos(theta2) + 2 * sin(k1 * (gama - theta2)) * sin(theta2) * k1 - k1^2 - 1) * k1))
This does include square roots. There are four places (total) that they occur, and all of them are the same expression,
(( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2)
It is not obvious what the sign of this is.
safi58
safi58 2017 年 3 月 15 日
yes, I am also getting similar kind of expression and dont know what to do next?
Walter Roberson
Walter Roberson 2017 年 3 月 15 日
What are the constraints on those variables, other than being real-valued? You mentioned capacitor voltage: does that imply they could be both positive and negative?
safi58
safi58 2017 年 3 月 16 日
Yes they could be both positive and negative values
. Here you can see mc which is capacitor voltage. my waveform would be something like that.
Walter Roberson
Walter Roberson 2017 年 3 月 19 日
My tests suggest that there are an infinite number of solutions, including ones in which several of the variables are 0.
safi58
safi58 2017 年 3 月 21 日
How did you do the test?
Walter Roberson
Walter Roberson 2017 年 3 月 21 日
I turned the calculation into a sum of squares of residues, and then ran a minimizer over it, testing a number of values. I noticed that along with the other solutions, that there were two clear intersecting lines along which the residues were 0, and those lines corresponded to a couple of the variables being 0.
safi58
safi58 2017 年 3 月 21 日
If you don't have a problem, can you please share the coding?
Walter Roberson
Walter Roberson 2017 年 3 月 21 日
The minimizer I used is not available as I am still developing it. However I should be able to provide the code for the function that would do the residue calculation. I do not have that handy at the moment as I am using a different device, but I will post it later.
The basic calculation in such a situation is to take each of the simultaneous equations, and subtract the right hand side from the left side to get an expression which would be be true if the result of the subtraction were 0. Do the same thing for each equation, getting an equation from each. Now, create a new expression which is the total of the squares of the other expressions. If all of the original equations were to balance then the contribution from each of the component expressions would be 0^2 = 0, and since the total of any number of 0 is 0, this new sum of squares would evaluate to 0 if all of individual equations balance.
This sum of squares formula has many local minima so you cannot simply use fmincon with it: you need some kind of global minimizer.
safi58
safi58 2017 年 3 月 22 日
Thank you Walter. Waiting for that.
Walter Roberson
Walter Roberson 2017 年 3 月 22 日
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.
safi58
safi58 2017 年 4 月 6 日
thanks Walter

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Mobile Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by