Unable to create Bode plot of H(s)=(s+10)/(s(s+5)^2)

5 ビュー (過去 30 日間)
Stanley
Stanley 2024 年 12 月 21 日
コメント済み: Paul 2024 年 12 月 22 日
% Case 1. T(s)=(s + 10)/[s(s + 5)^2]
% Case 1. expanded: (s+10)/(s^3 + 10s^2 + 25s)
num = [1 10];
den = [1 10 25 0];
sys = tf(num,den)
sys = s + 10 ------------------- s^3 + 10 s^2 + 25 s Continuous-time transfer function.
bode(sys)
grid on
Using the above code results in 2 error messages:
Error using DynamicSystem/bode (line 104) Line 104: throw(E)
A and B must be vectors.
Error in Bode_Pole_squared (line 10) -> This refers to: bode(sys)
bode(sys)
The code works without the 's' in the denominator (using (s+5)^2 only.)
  2 件のコメント
Walter Roberson
Walter Roberson 2024 年 12 月 21 日
I suspect that the problem is something along the lines of you having your own height.m function that is interfering with the MATLAB function. However, I did some tracing in the code, and I cannot see at the moment how the graphics are actually built, and I do not see any calls to height() or similar functions.
You should use
dbstop if caught error
and run again, and see where the problem is showing up.
Stanley
Stanley 2024 年 12 月 21 日
The code runs in the online version of Matlab. It does not run on my computer. I am going to re-install Matlab.

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

採用された回答

Hassaan
Hassaan 2024 年 12 月 21 日
編集済み: Hassaan 2024 年 12 月 21 日
% Define numerator and denominator
num = [1 10];
den = [1 10 25 0];
% Create the transfer function
sys = tf(num, den);
% Display the transfer function
disp(sys);
tf with properties: Numerator: {[0 0 1 10]} Denominator: {[1 10 25 0]} Variable: 's' IODelay: 0 InputDelay: 0 OutputDelay: 0 InputName: {''} InputUnit: {''} InputGroup: [1x1 struct] OutputName: {''} OutputUnit: {''} OutputGroup: [1x1 struct] Notes: [0x1 string] UserData: [] Name: '' Ts: 0 TimeUnit: 'seconds' SamplingGrid: [1x1 struct]
% Plot the Bode plot
bode(sys);
grid on;
The error you're encountering is due to the fact that the denominator provided in the code is incomplete for representing the transfer function properly in MATLAB. Specifically, the denominator vector [1 10 25 0] corresponds to s^3 + 10s^2 + 25s, but this form may lead to numerical instabilities or issues when attempting to compute the Bode plot because the transfer function has a pole at s=0 (a DC pole).
Also, see the recommendation from @Star Strider @Paul
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.
  1 件のコメント
Paul
Paul 2024 年 12 月 21 日
"The error you're encountering is due to the fact that the denominator provided in the code is incomplete for representing the transfer function properly in MATLAB."
As your own answer showed, there is no error.
How would one properly represent this transfer function in MATLAB?
"..., but this form may lead to numerical instabilities or issues when attempting to compute the Bode plot because the transfer function has a pole at s=0 (a DC pole)."
What is the basis of this statement?

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

その他の回答 (1 件)

Paul
Paul 2024 年 12 月 21 日
As shown after the edit of @Walter Roberson, the code runs fine here. Do you see the same output after executing the following commands?
num = [1 10];
den = [1 10 25 0];
sys = tf(num,den)
sys = s + 10 ------------------- s^3 + 10 s^2 + 25 s Continuous-time transfer function.
which tf(num,den)
/MATLAB/toolbox/control/ctrlmodels/@tf/tf.m % tf constructor
which bode(sys)
/MATLAB/toolbox/shared/controllib/engine/@DynamicSystem/bode.m % tf method
  2 件のコメント
Stanley
Stanley 2024 年 12 月 21 日
After running the online version, I get the same output. The problem may lie with default paths on my computer.
Paul
Paul 2024 年 12 月 22 日
The problem probaby lies with a function on your path that is shadowing a same-named function used by the Control System Toolbox.

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

カテゴリ

Help Center および File ExchangePlot Customization についてさらに検索

タグ

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by