数字滤波器设计
程序员文章站
2022-06-09 12:02:25
...
文章目录
留个坑,这几天就填
butterworth
chebyshev
ellipse
通一参数下,四类滤波器幅频响应比较
clear all
clc
fs=1e4;
Ts=1/fs;
fpass=3e3;
fstop=4e3;
Ap=3;
As=30;
Wp=fpass/fs;
Ws=fstop/fs;
[N,Wn]=buttord(Wp,Ws,Ap,As);
[butter_z,butter_p,butter_k]=butter(N,Wn);
sos = zp2sos(butter_z,butter_p,butter_k);
[butter_h,butter_w]=freqz(sos,1024);
[cheby1_z,cheby1_p,cheby1_k]=cheby1(N,Ap,Wp);
sos = zp2sos(cheby1_z,cheby1_p,cheby1_k);
[cheby1_h,cheby1_w]=freqz(sos,1024);
[cheby2_z,cheby2_p,cheby2_k]=cheby2(N,As,Wp);
sos=zp2sos(cheby2_z,cheby2_p,cheby2_k);
[cheby2_h,cheby2_w]=freqz(sos,1024);
[ellip_z,ellip_p,ellip_k] = ellip(N,Ap,As,Wp);
sos = zp2sos(ellip_z,ellip_p,ellip_k);
[ellip_h,ellip_w] = freqz(sos,1024);
figure
plot(butter_w/pi,20*log10(abs(butter_h)));
hold on
plot(cheby1_w/pi,20*log10(abs(cheby1_h)));
plot(cheby2_w/pi,20*log10(abs(cheby2_h)));
plot(ellip_w/pi,20*log10(abs(ellip_h)));
grid on
xlabel('Normalized Frequency (pi rad/sample)')
ylabel('Attenuation (dB)')
legend('butter','cheby1','cheby2','ellip')
axis([0 1 -40 3])