Error plotting bode diagram of a transfer function inside a matrix

12 ビュー (過去 30 日間)
Shah Fahad
Shah Fahad 2019 年 12 月 9 日
コメント済み: ahmed solyman 2023 年 1 月 11 日
I am trying to plot bode diagram of an element inside a matrix. The transfer function is alright if i plot G11 which is first row first column matrix. But the bode plot gives error. Is there a different way to plot such bode diagram ? My code is below.
syms s
G11=s-1;G12=s;
G21=-6;G22=s-2;
den=1.25*(s+1).*(s+2);
G=[G11, G12;G21, G22]/den;
G1=G(1,1);
G2=G(1,2);
G3=G(2,1);
G4=G(2,2);
bode(G1)
I even tried G11 by removing all G1...G4. But still doesnt work. Please guide.
  2 件のコメント
Star Strider
Star Strider 2019 年 12 月 9 日
Shah Fahad’s Answer moved here —
The error is:
Error using bode (line 83)
Not enough input arguments.
ahmed solyman
ahmed solyman 2023 年 1 月 11 日
Regarding MATLAB coding in particular using the bode(sys) code to get the bode diagram. When the numerator equals just a number like (10) without (S), there is an error in computing the bode magnitude because computing it as a 20log(k) “the rule” is not true in MATLAB. Because MATLAB takes into consideration it as log “ln”, not log10.
Please could you tell me how I can solve this issue?

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

採用された回答

Star Strider
Star Strider 2019 年 12 月 9 日
That is not the error.
The error is that you are using the Symbolic Math Toolbox when you need to be using the Control System Toolbox.
Try this:
s = tf('s');
G11=s-1;G12=s;
G21=-6;G22=s-2;
den=1.25*(s+1).*(s+2);
G=[G11, G12;G21, G22]/den;
G1=G(1,1);
G2=G(1,2);
G3=G(2,1);
G4=G(2,2);
bode(G1)
  2 件のコメント
Shah Fahad
Shah Fahad 2019 年 12 月 9 日
Dear @strider,
Thank you so much for your response. My code is working now.
Thank you.
Star Strider
Star Strider 2019 年 12 月 9 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Control System Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by