bode() yields wrong result

13 views (last 30 days)
Pascal Warten
Pascal Warten on 18 Dec 2021
Commented: Star Strider on 20 Dec 2021
Hello,
I would like to plot the Bode diagram of the following transfer function:
If I use the following code, I do not get appropriate results:
s = tf('s');
f1 = 0.99 * 18.88;
f2 = (1 + s / (2 * 3.1415 * 10.58)) / (1 + s / (s / (2 * 3.1415 * 26.74)));
f3 = (s / (2 * 3.1415 * 23.17)) / (1 + s / (2 * 3.1415 * 23.17));
f4 = (s / (2 * 3.1415 * 25.21)) / (1 + s / (2 * 3.1415 * 25.21));
f5 = 1 / (1 + s / (2 * 3.1415 * 48000));
bode(f1 * f2 * f3 * f4 * f5); grid on;
However, if I only plot one factor of the transfer function, it seems to work properly.
I would really appreaciate any help regarding this problem.
  4 Comments
Paul
Paul on 18 Dec 2021
Most impportantly, correct the typo in f2 as indicated below by @Star Strider.
Also, bode() always works with frequencies in rad/TimeUnit. If you want to specify the frequency in Hz, you can do it manually.
s = tf('s');
f1 = 0.99 * 18.88;
f2 = (1 + s / (2 * 3.1415 * 10.58)) / (1 + s / (2 * 3.1415 * 26.74));
f3 = (s / (2 * 3.1415 * 23.17)) / (1 + s / (2 * 3.1415 * 23.17));
f4 = (s / (2 * 3.1415 * 25.21)) / (1 + s / (2 * 3.1415 * 25.21));
f5 = 1 / (1 + s / (2 * 3.1415 * 48000));
whz = logspace(0,6);
[m,p] = bode(f1 * f2 * f3 * f4 * f5,2*pi*whz);
semilogx(whz,db(squeeze(m)))
Or use bodeplot() to plot in Hz directly
opts = bodeoptions;
opts.FreqUnits = 'Hz';
bodeplot(f1*f2*f3*f4*f5,opts);
Pascal Warten
Pascal Warten on 20 Dec 2021
Thank you for your tips regarding the specifications of the units.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 18 Dec 2021
There is a typographical error in ‘f2’ and correcting it produces the desired result —
s = tf('s');
f1 = 0.99 * 18.88;
f2 = (1 + s / (10.58)) / (1 + s / (26.74));
f3 = (s / (23.17)) / (1 + s / (23.17));
f4 = (s / (25.21)) / (1 + s / (25.21));
f5 = 1 / (1 + s / (48000));
figure
bode(f1 * f2 * f3 * f4 * f5, {0 5E+7*2*pi})
grid on;
.
  2 Comments
Pascal Warten
Pascal Warten on 20 Dec 2021
Thanks a lot!
Star Strider
Star Strider on 20 Dec 2021
As always, my pleasure!
.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with Control System Toolbox in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!