Make a bode plot without bode()?
조회 수: 42 (최근 30일)
이전 댓글 표시
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)
댓글 수: 4
Star Strider
2020년 3월 3일
Take the fft of the impulse output (get the time vector as well), then calculate the magnitude and phase and plot them.
Rik
2021년 3월 4일
답변 (1개)
Robert U
2020년 3월 4일
편집: Robert U
2020년 3월 4일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!