imaginary solution with solve
5 ビュー (過去 30 日間)
古いコメントを表示
I am trying to solve for 2 variables R2 and theta. Since the systems are not linear, equationsToMatrix and linsolve don't work. So I tried solve.
At one point I was getting a symbolic solution with i in it (which I have since been unable to reproduce) and so I tried to initialize the variables as 'real':
E = 447000;
v = 849968100;
deltay = .00127;
q = 40;
t = .000211;
R = .0525;
R2 = sym('R2','real');
theta = sym('theta','real');
eqns = [deltay*(2*E*t)/(q*(1-v)) == (R2^2)*(1-cos(theta)), sin(theta) == R/R2];
vars = [R2 theta];
[solR2,soltheta] = solve(eqns, vars)
% R2 = double(R2)
% theta = double(theta)
And now, instead of getting an imaginary solution, I get an empty symbolic variable. In the end, I'd like to get a real numeric solution for R2 and theta.
TIA! :)
0 件のコメント
採用された回答
Walter Roberson
2017 年 12 月 1 日
There are no real-valued solutions for R2 and theta for those constants.
The system of equations is a quadratic. The two forms are
R2 = 2*(-(1/4)/(((1/4)*R^2*(-1+v)*q+deltay*E*t)*(-1+v)*q))^(1/2)*t*deltay*E
theta = arctan(R/((-(1/4)/(((1/4)*R^2*(-1+v)*q+deltay*E*t)*(-1+v)*q))^(1/2)*t*deltay*E), (-2*deltay*E*t-R^2*(-1+v)*q)/(E*t*deltay))
and
R2 = -2*(-(1/4)/(((1/4)*R^2*(-1+v)*q+deltay*E*t)*(-1+v)*q))^(1/2)*t*deltay*E
theta = arctan(-R/((-(1/4)/(((1/4)*R^2*(-1+v)*q+deltay*E*t)*(-1+v)*q))^(1/2)*t*deltay*E), (-2*deltay*E*t-R^2*(-1+v)*q)/(E*t*deltay))
If you examine the ^(1/2) portions, you will see that they involve -1 times an expression. When all of the constants are positive and v is greater than 1, then the expression is strictly positive, leading to a negative inside the sqrt, which will be imaginary.
At least one of your constants would need to change sign, or your v would need to be less than 1, in order to be taking the square root of a positive value there.
24 件のコメント
David Goodmanson
2017 年 12 月 3 日
If R/R2 is positive (and less than one) then asin outputs into the first quadrant, so you get check_theta = 0.1513. But since sin(theta) = sin(pi-theta), (pi-theta) is also a valid solution for asin. Indeed if you compare check_theta with theta from the acos calculation, then if you check whether (pi - check_theta) = theta, that checks out.
Geometrically, is check_theta really the angle that counts? It's certainly in the range you wanted.
You did not yet mention what deltay is. Is it a deflection?
その他の回答 (1 件)
monarch
2017 年 12 月 3 日
3 件のコメント
David Goodmanson
2017 年 12 月 4 日
編集済み: David Goodmanson
2017 年 12 月 7 日
Could you describe the experimental setup, for example is it a hemisphere, and how you are measuring y, and how is your angle theta measured or defined?
I'm not sure what you don't like about the plot that you posted since it looks like it peaks out at .0048 just like it should.
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!