一、实验目的 1.低通滤波器到数字高通滤波器的转化为例,了解并掌握数字滤波器的频带变换方法。 2.观察变化前后的数字滤波器的频域特性的变化。 3.掌握实现数字滤波器频带变换的MATLAB 编程方法。 二、实验原理 前面的实验都是设计低通型滤波器,实际的应用中我们需要的还有其他类型,如高通,带通和带阻滤波器。将一个低通滤波器的频带进行变换,就可以得到另外的频率选择性滤波器。
参考流程图:
四、实验报告要求及思考题 1.简述实验目的及原理 2.整理好经过运行并证明是正确的实验程序并加上注释。绘出相应的图形。
代码语言:javascript复制wp=0.2*pi;
ws=0.3*pi;
wc=0.6*pi;
rp=1;
as=15;
Fs=1000;
T=1/Fs;
op=(2/T)*tan(wp/2);
os=(2/T)*tan(ws/2);
omc=(2/T)*tan(wc/2);
figure;
[n,oc]=cheb1ord(op,os,rp,as,'s');
[z,p,k]=cheb1ap(n,rp);
b=k*real(poly(z));
a=real(poly(p));
[b,a]=lp2lp(b,a,oc);
[b,a]=bilinear(b,a,Fs);
[H,w]=freqz(b,a);
subplot(221),plot(w/pi,abs(H));
title('切比1低通幅频特性');xlabel('单位:Xpi');set(gca,'Xtick',[0.2,0.3]);grid;
subplot(222),plot(w/pi,angle(H));title('切比1低通相频特性');xlabel('单位:Xpi');
set(gca,'Xtick',[0.2,0.3]);grid;
subplot(223),plot(w/pi,20*log10(abs(H)/max(abs(H))));title('切比1低通分贝幅频特性');
xlabel('单位:Xpi');
set(gca,'Xtick',[0.2,0.3]);grid;
subplot(224),grpdelay(b,a);
az=-cos((wp wc)/2)/cos((wp-wc)/2);
Nz=[-az,-1];
Dz=[1,az];
[b,a]=zmapping(b,a,Nz,Dz);
[H,w]=freqz(b,a);
figure;
subplot(221),plot(w/pi,abs(H));
title('切比1数字频带变换');xlabel('单位:Xpi');ylabel('高通幅频特性');set(gca,'Xtick',[0.6]);grid;
subplot(222),plot(w/pi,angle(H));title('切比1数字频带变换');ylabel('高通相频特性');xlabel('单位:Xpi');
set(gca,'Xtick',[0.6]);grid;
subplot(223),plot(w/pi,20*log10(abs(H)/max(abs(H))));title('切比1数字频带变换');
ylabel('高通分贝幅频特性');
xlabel('单位:Xpi');
set(gca,'Xtick',[0.6]);grid;
subplot(224),grpdelay(b,a);
figure;
[n,oc]=cheb1ord(op,os,rp,as,'s');
[z,p,k]=cheb1ap(n,rp);
b=k*real(poly(z));
a=real(poly(p));
[b,a]=lp2hp(b,a,omc);
[b,a]=bilinear(b,a,Fs);
[H,w]=freqz(b,a);
subplot(221),plot(w/pi,abs(H));
title('切比1模拟频带变换');xlabel('单位:Xpi');ylabel('高通幅频特性');set(gca,'Xtick',[0.6]);grid;
subplot(222),plot(w/pi,angle(H));title('切比1模拟频带变换');ylabel('高通相频特性');xlabel('单位:Xpi');
set(gca,'Xtick',[0.6]);grid;
subplot(223),plot(w/pi,20*log10(abs(H)/max(abs(H))));title('切比1模拟频带变换');
ylabel('高通分贝幅频特性');
xlabel('单位:Xpi');
set(gca,'Xtick',[0.6]);grid;
subplot(224),grpdelay(b,a);
调用的函数:zmapping.m
%%数字滤波器频率变换
%zmapping.m
function [bz az]=zmapping(bZ,aZ,Nz,Dz)
%Frequency band Trandformation from z-domain to z-domain
%______ ____________
% [bz az]=zmapping(bZ,aZ,Nz,Dz);
% performs:
% b(z) b(Z) |
% --------------| N(z)
% a(z) a(Z) | Z=----------------
% | D(z)
% |
% hi,you little ass
bzord=(length(bZ)-1)*(length(Nz)-1);
azord=(length(aZ)-1)*(length(Dz)-1);
bz=zeros(1,bzord 1);
for k=0:bzord
pln=[1];
for l=0:k-1
pln=conv(pln,Nz);
end
pld=[1];
for l=0:bzord-k-1
pld=conv(pld,Dz);
end
bz=bz bZ(k 1)*conv(pln,pld);
end
az=zeros(1,azord 1);
for k=0:azord
pln=[1];
for l=0:k-1
pln=conv(pln,Nz);
end
pld=[1];
for l=0:bzord-k-1
pld=conv(pld,Dz);
end
az=az aZ(k 1)*conv(pln,pld);
end
az1=az(1);
az=az/az1;
bz=bz/az1;