📄 bpiir2butter.m
字号:
clc;
Fs=8000; % Sampling frequency 8 kHz
Fls=250;
Flp=280;
Fup=320;
Fus=350;
Wp=[2*Flp/Fs,2*Fup/Fs]; % Normalized passband edge frequency
Ws=[2*Fls/Fs,2*Fus/Fs]; % Normalized stopband edge frequency
Rp=3; % Passband ripple in dB
Rs=20; % Stopband attenuation in dB
%Wp = [0.28/8 0.32/8]; Ws = [0.27/8 0.33/8]; Rp = 3; Rs = 20;
% Filter design
[N,Wn]=buttord(Wp,Ws,Rp,Rs); % Filter order selection
[b,a]=butter(N,Wn); % Butterworth filter design
[Z,P,K]=tf2zp(b,a); % Transfer function to zero-pole
[sos,G]=zp2sos(Z,P,K) % Zero-pole to 2nd-order section
[hw,w]=freqz(b,a);
subplot(3,2,1);
plot(w/pi,20*log10(abs(hw)));grid
axis([0,1,-80,5]);xlabel('ω/π');
ylabel('幅度(dB)')
subplot(3,2,3);plot(w/pi,angle(hw));
grid;axis([0,1,-pi,pi]);
xlabel('ω/π');ylabel('相位(rad)');
Coeff1=sos( : ,[5,6] )*16384;
Coeff2=sos( : ,[1,2,3] )*16384;
Coeff2=Coeff2*0.017;
Coeff=[Coeff1,Coeff2];
Coeff=round(Coeff)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -