imaginary solution with solve
3 次查看(过去 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!