bpiir2butter.m

来自「matlab IIR带通 滤波器设计 m文件 巴特沃斯」· M 代码 · 共 35 行

M
35
字号
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 + =
减小字号Ctrl + -
显示快捷键?