フィルターのクリア

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.

2 ビュー (過去 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)

採用された回答

Walter Roberson
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.
  1 件のコメント
aldo angulo
aldo angulo 2017 年 11 月 16 日
Thanks for the help, really helped me go faster through the problems instead of doing everything by hand on paper.

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

その他の回答 (1 件)

Birdman
Birdman 2017 年 11 月 16 日
編集済み: Birdman 2017 年 11 月 16 日
y = vpasolve( ( 5 / ( (-1.5*w^2)^2 + ( w - 0.5*w^3 )^2 )^(1/2) ) - 1 );
disp(y)
Solve returns symbolic solutions, vpasolve returns numeric solutions.
  2 件のコメント
aldo angulo
aldo angulo 2017 年 11 月 16 日
Thanks a lot, it solved the issue and you saved me a lot of time. I was using the 2011 version and the command solve would get the job done but I really had no clue about what you stated "Solve returns symbolic solutions, vpasolve returns numeric solutions."
Birdman
Birdman 2017 年 11 月 16 日
Walter's answer explains it.

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

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by