MATLAB Answers

Make a bode plot without bode()?

104 views (last 30 days)
Kebels3
Kebels3 on 3 Mar 2020
Edited: Robert U on 4 Mar 2020
Is there a way to make a bode plot without using the function bode()?
This is the transfer function which i am working with
s = tf('s'); H = (s^3 + 2*s + 5)/(s^4+7*s^3+4*s^2+8*s+12)

  3 Comments

Bhaskar R
Bhaskar R on 3 Mar 2020
bodeplot(H); %??
M
M on 3 Mar 2020
You can easily plot a handmade bode plot:
If you wish to draw the real bode plot, this is another story.
Can you use the freqs function ?
Star Strider
Star Strider on 3 Mar 2020
Take the fft of the impulse output (get the time vector as well), then calculate the magnitude and phase and plot them.

Sign in to comment.

Accepted Answer

Robert U
Robert U on 4 Mar 2020
Edited: Robert U on 4 Mar 2020
Hi Jeroen von der Klip,
Your task sounds as you want to omit the use of a toolbox. Even though the control system toolbox offers much more extras with bode-command or bodeplot-command you can - of course - plot the transfer function from scratch.
% transfer function as anonymous function
H = @(s)(s.^3 + 2*s + 5)./(s.^4+7*s.^3+4*s.^2+8*s+12);
% frequency vector of domain to be evaluated
omega = 2 * pi * logspace(-3,3,1000);
% magnitude estimation
mag = abs(H(1j*omega));
magDB = 20 * log10(mag);
% phase estimation
phaseDeg = rad2deg( angle(H(1j*omega)) );
% plot results
fh = figure;
ah = subplot(2,1,1,'Parent',fh);
bh = subplot(2,1,2,'Parent',fh);
semilogx(ah,omega/2/pi,magDB)
semilogx(bh,omega/2/pi,phaseDeg)
ah.XGrid = 'on';
ah.YGrid = 'on';
bh.XGrid = 'on';
bh.YGrid = 'on';
ah.XLabel.String = 'frequency [Hz]';
ah.YLabel.String = 'magnitude [dB]';
bh.XLabel.String = 'frequency [Hz]';
bh.YLabel.String = 'phase angle [°]';
ah.Title.String = func2str(H);
Kind regards,
Robert

  0 Comments

Sign in to comment.

More Answers (0)