您好,欢迎访问三七文档
实验7用MATLAB设计IIR数字滤波器一、实验目的:1、加深对IIR数字滤波器的基本设计方法的理解。2、掌握用模拟滤波器原型设计IIR数字滤波器的方法。3、了解MATLAB有关IIR数字滤波器设计的子函数的调用方法。二、实验内容及步骤1、阅读并输入实验原理中介绍的例题程序,观察输出的数据和图形,结合基本原理理解每一条语句的含义。2、用双线性变换法设计切比雪夫Ⅱ型数字滤波器,列出传递函数并描绘模拟和数字滤波器的幅频响应曲线。①设计一个数字低通滤波器,要求:ωp=0.2П,Rp=1dB;阻带:ωs=0.35П,As=15dB,滤波器采样频率Fs=10Hz。wp=0.2*pi;%滤波器的通带截止频率ws=0.35*pi;%滤波器的阻带截止频率Rp=1;As=15;%滤波器的通阻带衰减指标ripple=10^(-Rp/20);%滤波器的通带衰减对应的幅度值Attn=10^(-As/20);%滤波器的阻带衰减对应的幅度值%转换为模拟滤波器的技术指标Fs=10;T=1/Fs;Omgp=(2/T)*tan(wp/2);%原型通带频率的预修正Omgs=(2/T)*tan(ws/2);%原型阻带频率的预修正%模拟原型滤波器计算[n,Omgc]=buttord(Omgp,Omgs,Rp,As,'s')%计算阶数n和截止频率[z0,p0,k0]=buttap(n);%设计归一化的巴特沃思模拟滤波器原型ba1=k0*real(poly(z0));%求原型滤波器的系数baa1=real(poly(p0));%求原型滤波器的系数a[ba,aa]=lp2lp(ba1,aa1,Omgc);%变换为模拟低通滤波器%也可将以上4行替换为[bb,aa]=butter(n,Omgc,'s');直接求模拟滤波器系数%用双线性变换法计算数字滤波器系数[bd,ad]=bilinear(ba,aa,Fs)[sos,g]=tf2sos(bd,ad)%转换成级联型%求数字系统的频率特性[H,w]=freqz(bd,ad);dbH=20*log10((abs(H)+eps)/max(abs(H)));subplot(2,2,1);plot(w/pi,abs(H));ylabel('|H|');title('幅度响应');axis([0,1,0,1.1]);set(gca,'XTickMode','manual','XTick',[0,0.25,0.4,1]);set(gca,'YTickMode','manual','YTick',[0,Attn,ripple,1]);gridsubplot(2,2,2);plot(w/pi,angle(H)/pi);ylabel('\phi');title('相位响应');axis([0,1,-1,1]);set(gca,'XTickMode','manual','XTick',[0,0.25,0.4,1]);set(gca,'YTickMode','manual','YTick',[-1,0,1]);gridsubplot(2,2,3);plot(w/pi,dbH);title('幅度响应(dB)');ylabel('dB');xlabel('频率(\pi)');axis([0,1,-40,5]);set(gca,'XTickMode','manual','XTick',[0,0.25,0.4,1]);set(gca,'YTickMode','manual','YTick',[-50,-15,-1,0]);gridsubplot(2,2,4);zplane(bd,ad);axis([-1.1,1.1,-1.1,1.1]);title('零极点图');00.250.4100.17780.89131|H|幅度响应00.250.41-101相位响应00.250.41-15-10幅度响应(dB)dB频率()-101-1-0.500.51RealPartImaginaryPart零极点图n=4Omgc=7.9909bd=Columns1through40.00920.03670.05500.0367Column50.0092ad=Columns1through41.0000-2.03251.8204-0.7706Column50.1294sos=Columns1through41.00002.00151.00151.00001.00001.99850.99851.0000Columns5through6-0.88560.2220-1.14690.5827g=0.0092②设计一个数字高通滤波器,要求:ωp=0.35П,Rp=1dB;阻带:ωs=0.2П,As=15dB,滤波器采样频率Fs=10Hz。fs=1.75;fp=1;Fs=10;T=1/Fs;wp=fp/Fs*2*pi;%滤波器的通带截止频率ws=fs/Fs*2*pi;%滤波器的阻带截止频率Rp=1;As=15;%滤波器的通阻带衰减指标ripple=10^(-Rp/20);%滤波器的通带衰减对应的幅度值Attn=10^(-As/20);%滤波器的阻带衰减对应的幅度值%转换为模拟滤波器的技术指标Omgp=(2/T)*tan(wp/2);%原型通带频率的预修正Omgs=(2/T)*tan(ws/2);%原型阻带频率的预修正%模拟原型滤波器计算[n,Omgc]=ellipord(Omgp,Omgs,Rp,As,'s')%计算阶数n和截止频率[z0,p0,k0]=ellipap(n,Rp,As);%设计归一化的椭圆滤波器原型ba1=k0*real(poly(z0));%求原型滤波器的系数baa1=real(poly(p0));%求原型滤波器的系数a[ba,aa]=lp2hp(ba1,aa1,Omgc);%变换为模拟高通滤波器%用双线性变换法计算数字滤波器系数[bd,ad]=bilinear(ba,aa,Fs)%求数字系统的频率特性[H,w]=freqz(bd,ad);dbH=20*log10((abs(H)+eps)/max(abs(H)));subplot(2,2,1);plot(w/2/pi*Fs,abs(H),'k');ylabel('|H|');title('幅度响应');axis([0,Fs/2,0,1.1]);set(gca,'XTickMode','manual','XTick',[0,fs,fp,Fs/2]);set(gca,'YTickMode','manual','YTick',[0,Attn,ripple,1]);gridsubplot(2,2,2);plot(w/2/pi*Fs,angle(H)/pi*180,'k');ylabel('\phi');title('相位响应');axis([0,Fs/2,-180,180]);set(gca,'XTickMode','manual','XTick',[0,fs,fp,Fs/2]);set(gca,'YTickMode','manual','YTick',[-180,0,180]);gridsubplot(2,2,3);plot(w/2/pi*Fs,dbH);title('幅度响应(dB)');ylabel('dB');xlabel('频率(\pi)');axis([0,Fs/2,-40,5]);set(gca,'XTickMode','manual','XTick',[0,fs,fp,Fs/2]);set(gca,'YTickMode','manual','YTick',[-50,-20,-1,0]);gridsubplot(2,2,4);zplane(bd,ad);axis([-1.1,1.1,-1.1,1.1]);title('零极点图');n=2Omgc=12.2560bd=0.5214-0.91870.5214ad=1.0000-0.75160.4492011.75500.17780.89131|H|幅度响应011.755-1800180相位响应011.755-20-10幅度响应(dB)dB频率()-101-1-0.500.51RealPartImaginaryPart零极点图3、设计一个切比雪夫Ⅱ型数字带通滤波器,要求:p1p2f=200Hz,f=300Hz,Rp=1dB;阻带s1s2sf=150Hz,f=350Hz,A=20dB,滤波器采样周期Ts=0.001s。列出传递函数并作频率响应曲线和零极点分布图。wp1=0.4*pi;wp2=0.6*pi;%滤波器的通带截止频率ws1=0.3*pi;ws2=0.7*pi;%滤波器的阻带截止频率Rp=1;As=20;%滤波器的通阻带衰减指标%转换为模拟滤波器的技术指标T=0.001;Fs=1/T;Omgp1=(2/T)*tan(wp1/2);Omgp2=(2/T)*tan(wp2/2);Omgp=[Omgp1,Omgp2];Omgs1=(2/T)*tan(ws1/2);Omgs2=(2/T)*tan(ws2/2);Omgs=[Omgs1,Omgs2];bw=Omgp2-Omgp1;w0=sqrt(Omgp1*Omgp2);%模拟通带带宽和中心频率%bw=Omgs2-Omgs1;w0=sqrt(Omgs1*Omgs2);设计cheb2时用模拟阻带带宽和中心频率,ripple=10^(-Rp/20);%滤波器的通带衰减对应的幅度值Attn=10^(-As/20);%滤波器的阻带衰减对应的幅度值%模拟原型滤波器计算[n,Omgn]=cheb1ord(Omgp,Omgs,Rp,As,'s')%计算阶数n和截止频率[z0,p0,k0]=cheb1ap(n,Rp);%设计归一化的模拟滤波器原型%[n,Omgn]=cheb2ord(Omgp,Omgs,Rp,As,'s')%[z0,p0,k0]=cheb2ap(n,As);%设计归一化的cheb2型模拟滤波器原型ba1=k0*real(poly(z0));%求原型滤波器的系数baa1=real(poly(p0));%求原型滤波器的系数a[ba,aa]=lp2bp(ba1,aa1,w0,bw);%变换为模拟带通滤波器%用双线性变换法计算数字滤波器系数[bd,ad]=bilinear(ba,aa,Fs)%求数字系统的频率特性[H,w]=freqz(bd,ad);dbH=20*log10((abs(H)+eps)/max(abs(H)));subplot(2,2,1);plot(w/pi,abs(H));ylabel('|H|');title('幅度响应');axis([0,1,0,1.1]);set(gca,'XTickMode','manual','XTick',[0,0.2,0.3,0.7,0.8]);set(gca,'YTickMode','manual','YTick',[0,Attn,ripple,1]);gridsubplot(2,2,2);plot(w/pi,angle(H)/pi*180);ylabel('\phi');title('相位响应');axis([0,1,-180,180]);set(gca,'XTickMode','manual','XTick',[0,0.2,0.3,0.7,0.8]);set(gca,'YTickMode','manual','YTick',[-180,-90,0,90,180]);gridsubplot(2,2,3);plot(w/pi,dbH);title('幅度响应(dB)');ylabel('dB');xlabel('频率(\pi)');axis([0,1,-60,5]);set(gca,'XTickMode','manual','XTick',[0,0.2,0.3,0.7,0.8]);set(gca,'YTickMode','manual','YTick',[-60,-20,-1,0]);gridsubplot(2,2,4);zplane(bd,ad);axis
本文标题:数字信号处理实验七
链接地址:https://www.777doc.com/doc-5928765 .html