wp=0.2*pi;ws=0.6*pi;rp=3;rs=40; %数字滤波器指标
Omgp=tan(wp/2)
Omgs=tan(ws/2) %转化为模拟滤波器指标(K=1)
Fs=0.5;
%模拟原型滤波器计算
[N,wo]=cheb1ord(Omgp,Omgs,rp,rs,'s')%计算阶数N和截止频率wo
[b,a]=cheby1(N,rp,wo,'s') %求原型滤波器系数b,a
[Ha,Omg]=freqs(b,a); %求模拟系统频率特性
dbHa=20*log((abs(Ha)+eps)/max(abs(Ha)));%求分贝值,加eps以避开0点
%计算数字滤波器
[bd,ad]=bilinear(b,a,0.5); %用双线性变换法求数字滤波器系数bd,ad
[H,w]=freqz(bd,ad); %求数字系统频率特性
dbH=20*log10(abs(H)/max(abs(H))); %化为分贝值
%画图
subplot(3,2,1),plot(Omg*Omgp/2/pi,dbHa),grid
title('a 模拟幅度响应(dB)');ylabel('幅度/dB');xlabel('f/Hz');
subplot(3,2,2),plot(w/pi,abs(H))
title('b 幅度响应');axis([0,1,0,1]);
subplot(3,2,3),plot(w/pi,dbH),grid
title('c 幅度响应(dB)');axis([0,1,-300,100]);
subplot(3,2,4),plot(w/pi,dbH),grid
title('d 幅度响应(dB)');axis([0,0.7,-60,5]);
subplot(3,2,5),plot(w/pi,angle(H)/pi)
title('e 相位响应');axis([0,1,-1,1]);
subplot(3,2,6),zplane(bd,ad)
title('f 零极图');axis([-1.1,1.1,-1.1,1.1]);
Omgp =
0.3249
Omgs =
1.3764
N =
3
wo =
0.3249
b =
0 0 0 0.0086
a =
1.0000 0.1941 0.0980 0.0086
Published with MATLAB? R2012b