When I enter the following code in 2017 MATLAB it gives me a nonsense answer, or so it is to me. does some one know how to fix it? i am trying to solve for w and the second one does give the right answer but the first one does not.
1 次查看(过去 30 天)
显示 更早的评论
Code entered:
format compact
syms w;
y = solve( ( 5 / ( (-1.5*w^2)^2 + ( w - 0.5*w^3 )^2 )^(1/2) ) - 1 );
x = solve( (-pi/2) - atan(w/2) - atan(w) + (pi) );
disp(y);
disp(x);
num = [5];
den = [0.5 1.5 1 0];
G = tf(num, den);
bode(G), grid
margin(num, den);
answer given:
root(z^6 + 5*z^4 + 4*z^2 - 100, z, 1)
root(z^6 + 5*z^4 + 4*z^2 - 100, z, 2)
root(z^6 + 5*z^4 + 4*z^2 - 100, z, 3)
root(z^6 + 5*z^4 + 4*z^2 - 100, z, 4)
root(z^6 + 5*z^4 + 4*z^2 - 100, z, 5)
root(z^6 + 5*z^4 + 4*z^2 - 100, z, 6)
2^(1/2)
0 个评论
采纳的回答
Walter Roberson
2017-11-16
I would suggest instead
vpa(y)
There are 6 solutions. vpasolve() would pick one of them, but there is no inherent reason to favour one over another.
If it is known that the solution should be a positive value, then add that as an assumption:
syms w positive
y = solve( ( 5 / ( (-1.5*w^2)^2 + ( w - 0.5*w^3 )^2 )^(1/2) ) - 1 );
This will get you the exact solution, though you may wish to simplify(y), which would give you
(3^(1/2)*((1315 - 6*47973^(1/2))^(1/3) + (6*47973^(1/2) + 1315)^(1/3) - 5)^(1/2))/3
You could vpa() that or you could double() that depending on your needs.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!