To determine whether the system is stable.

35 ビュー (過去 30 日間)
William
William 2021 年 9 月 21 日
回答済み: Star Strider 2021 年 9 月 21 日
I have writen the code to determine the stability of a system. However, the result keeps saying that 'System is not stable' even if I checked the value of pm in workspace and it shows that pm equals to 1, which means that the system is marginally stable. What's wrong with it?
b = [1 0 0 -1 0];
a = [1 0 0 0 -1];
zplane(b,a)
p = roots(a);
pm = abs(p);
if max(pm) <= 1
disp('System is stable');
else
disp('System is not stable');
end
end

採用された回答

Star Strider
Star Strider 2021 年 9 月 21 日
Welcome to the wonderful world of floating-point approximation error!
See ‘Check’ and ‘Check_max’ for an illustration of the probllem:
format long % View Full Precision Results
b = [1 0 0 -1 0];
a = [1 0 0 0 -1];
zplane(b,a)
p = roots(a)
p =
-1.000000000000000 + 0.000000000000000i 0.000000000000000 + 1.000000000000000i 0.000000000000000 - 1.000000000000000i 1.000000000000000 + 0.000000000000000i
pm = abs(p)
pm = 4×1
1.000000000000000 1.000000000000000 1.000000000000000 1.000000000000000
Check = pm-1
Check = 4×1
1.0e+-15 * 0.444089209850063 -0.444089209850063 -0.444089209850063 -0.111022302462516
Check_max = max(pm)-1
Check_max =
4.440892098500626e-16
if max(pm) <= 1
disp('System is stable');
else
disp('System is not stable');
end
System is not stable
% end
See the documentation on Floating-Point Numbers for an extended discussion on this topic.
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFilter Analysis についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by