3、,rp,rs,'s');[z,p,k]=buttap(N);[Bap,Aap]=zp2tf(z,p,k);[b,a]=lp2lp(Bap,Aap,Wn);[bz,az]=impinvar(b,a,Fs);figure;[H,W]=freqz(bz,az);plot(W*Fs/(2*pi),abs(H));grid;xlabel('频率/Hz');ylabel('幅值');%双线性变换法wp=0.2*pi;ws=0.3*pi;rp=1;rs=15;Ts=0.01;Fs=1/Ts;Wp=(1/Ts)*tan(wp/
4、2);Ws=(1/Ts)*tan(ws/2);[N,Wn]=buttord(Wp,Ws,rp,rs,'s');[Z,P,K]=buttap(N);[Bap,Aap]=zp2tf(Z,P,K);[b,a]=lp2lp(Bap,Aap,Wn);[bz,az]=bilinear(b,a,1/Ts);[H,W]=freqz(bz,az);holdon;plot(W*Fs/(2*pi),abs(H),'m');grid;xlabel('频率');ylabel('幅度');%用完全设计函数设计wp=0.2;ws=0.3;r
5、p=1;rs=15;Ts=0.01;Fs=1/Ts;[N,Wn]=buttord(wp,ws,rp,rs);[b,a]=butter(N,Wn);[H,W]=freqz(b,a);holdon;plot(W*Fs/(2*pi),abs(H),'k');grid;xlabel('频率/Hz');ylabel('幅值');执行程序,比较设计结果:【例5-8】用冲激响应不变法设计数字低通滤波器,要求通带和阻带具有单调下降特性。指标参数要求:通带截止频率为200Hz,通带最大衰减为δ1=0.8;阻带截止频率为300Hz
6、,阻带最小衰减δ2=20dB,采样时间间隔T=1ms1.应用matlab函数设计该滤波器,并观察滤波器的幅频特性曲线。2.若输入信号x(t)=2sin400pi*t+sin700pi*t+ω(t),ω(t)为随机信号,应用该滤波器对信号进行滤波器变换。fp=200;Ap=0.8;fr=300;Ar=20;T=0.001;fs=1/T;Wp=2*pi*fp;Wr=2*pi*fr;[N,Wn]=buttord(Wp,Wr,Ap,Ar,'s');[b,a]=butter(N,Wn,'s');[bz,az]=impin
7、var(b,a,fs);[H,W]=freqz(bz,az);figure(1);plot(W*fs/(2*pi),abs(H));gridon;title('低通滤波器频率特性曲线');xlabel('频率/Hz');ylabel('幅值');n=0:199;t=n*T;x=2*sin(400*pi*t)+sin(700*pi*t)+randn(1,size(t));y=filter(bz,az,x);figure(2);subplot(3,1,1);plot(n,x,'r');xlabel('t');yla
8、bel('x(t)');title('原信号x(t)');subplot(3,1,2);x1=2*sin(400*pi*t)+sin(700*pi*t);plot(n,x1,'b');xlabel('t');ylabel('x1(t)');title('信号(t)');subplot(3,1,3)plot(n,y,'y');xlabel('t');ylabel('y(t)');titl