Bode diagram for a Butterworth filter
조회 수: 24 (최근 30일)
이전 댓글 표시
Hi,
I want help in doing a Bode diagram for a 8th order Butterworth passband with passband between 2 and 12 Hz. Sampling frequency of 60 Hz,
Can you help?
Thank you!
댓글 수: 0
답변 (2개)
Jon
2022년 7월 28일
What specific problems or errors are you getting? Here is an example that maybe you can adapt to your situation
fs = 1000; % sampling frequency Hz
fn = fs/2; % Nyquist frequency Hz
fp = [2,12] % passband Hz
fpn = fp/fn % normalized passband (fraction of Nyquist Frequency)
N = 8; % filter order
% calculate butterwork filter
[A,B,C,D] = butter(N,fpn,"bandpass")
% define linear system
sys = ss(A,B,C,D,1/fs);
% make bode plot
bode(sys)
댓글 수: 0
Star Strider
2022년 7월 28일
Fs = 60; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
[z,p,k] = butter(8, [2 12]/Fn); % Design Filter, Return [Zero, Pole, Gain] Output
[sos,g] = zp2sos(z,p,k); % Convert To Second-Order-Section Representation For Stability
figure
freqz(sos, 2^16, Fs) % Plot Filter Bode Plot
A better way to determine the filter order is to begin with the buttord funciton, since it allows other arguments (for example the stopband limits and and stopband attenuation) to be defined as well. (I generally prefer elliptic filters, since they are computationally more efficient.)
.
댓글 수: 2
Jon
2022년 7월 28일
So I guess if you have the signal processing toolbox but not the control system toolbox this would be an alternative. If the OP has the control system toolbox, is there any reason not to use bode (as I outlined previously)
Star Strider
2022년 7월 28일
Convenience.
The freqz function requires only the code necessary to call it with the zp2sos output. No other code is required.
참고 항목
카테고리
Help Center 및 File Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!