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 visualización (últimos 30 días)
Mostrar comentarios más antiguos
aldo angulo
el 16 de Nov. de 2017
Comentada: Birdman
el 16 de Nov. de 2017
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 comentarios
Respuesta aceptada
Walter Roberson
el 16 de Nov. de 2017
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.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!