bode() yields wrong result
13 views (last 30 days)
Show older comments
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
on 18 Dec 2021
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);
Accepted Answer
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
More Answers (0)
See Also
Categories
Find more on Get Started with Control System Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



