實驗:用雙線性變換法設計IIR數(shù)字濾波器.doc
實驗三:用雙線性變換法設計IIR數(shù)字濾波器(設計性 4學時)一.實驗目的:(1)熟悉用雙線性變換法設計IIR數(shù)字濾波器的原理與方法。(2)掌握數(shù)字濾波器的計算機仿真方法。(3)通過觀察對實際心電圖信號的濾波作用,獲得數(shù)字濾波的感性知識。 二.實驗內容及步驟:(1) 用雙線性變換法設計一個巴特沃斯低通IIR數(shù)字濾波器,設計指標參數(shù)為:在通帶內頻率低于0.2pi時,最大衰減小于1dB;在阻帶內0.3pi , pi 頻率區(qū)間上,,最小衰減大于15dB;(2) 以 0.02pi為采樣間隔,打印出數(shù)字濾波器在頻率區(qū)間 0, 0.5pi上的幅頻響應特性曲線;(3) 用所設計的濾波器對實際心電圖信號采樣序列(在本實驗后面給出)進行仿真濾波處理,并分別打印出濾波前后的心電圖波形圖,觀察總結濾波作用與效果。(4)采用不同階數(shù)的Butterworth 低通濾波器,比較濾波效果。三.實驗步驟:(1)復習有關巴特沃斯模擬濾波器設計和用雙線性變換法設計IIR數(shù)字濾波器的內容,按照教材例6.4.2,用雙線性變換法設計數(shù)字濾波器系統(tǒng)函數(shù)H(z)。方法一:教材例6.4.2種已求出滿足本實驗要求的數(shù)字濾波器系統(tǒng)函數(shù):方法二:根據(jù)設計指標,調用MATLAB信號處理工具箱函數(shù)buttord和butter,也可得到H(z)。(2)編寫濾波器仿真程序,計算H(z)對心電圖信號采樣序列x(n)的相應序列y(n)。(3)在通過計算機上運行仿真濾波程序,并調用通用繪圖子程序,完成實驗內容(2)和(3)。本實驗要用的MATLAB繪圖函數(shù)參閱教材。四.,思考題:用雙線性變換法設計數(shù)字濾波器過程中,變換公式:s=中T的取值,對設計結果有無影響? 為什么? 五.實驗報告要求(1)簡述實驗目的及原理;(2)由所打印的特性曲線及設計過程簡述雙線性變換法的特點;(3)對比濾波前后的心電圖信號波形,說明數(shù)字濾波器的濾波過程與濾波作用; (4) 簡要回答思考題.六:心電圖信號采樣序列 x(n):人體心電圖信號在測量過程中往往受到工業(yè)高頻干擾,所以必須經(jīng)過低通濾波處理后,才能作為判斷心臟功能的有用信息。下面給出一實際心電圖信號采樣序列樣式本x(n),其中存在高頻干擾,在實驗中,以x(n)作為輸入序列,濾除其中的干擾成分。 x(n) = -4 , -2, 0, -4, -6, -4, -2, -4, -6, -6, -4, -4, -6, -6, -2, 6, 12, 8, 0, -16 -38, -60, -84, -90, -66, -32, -4, -2, -4, 8,12, 12 , 10, 6, 6, 6, 4, 0, 0, 0 0, 0, -2, -4, 0, 0, 0, -2, -2, 0,0 , -2, -2, -2, -2, 0參考程序:一;T=1;Fs=1/T;wpz=0.2;wsz=0.3;wp=2*tan(wpz*pi/2);ws=2*tan(wsz*pi/2);rp=1;rs=15;N,wc=buttord(wp,ws,rp,rs,s);B,A=butter(N,wc,s);fk=0:1/512:1;wk=2*pi*fk;Hk=freqs(B,A,wk);subplot(2,2,1);plot(fk,20*log10(abs(Hk);grid on;xlabel(omega/pi);ylabel(幅度(dB);axis(0,1,-100,5);title(b);N,wc=buttord(wpz,wsz,rp,rs);Bz,Az=butter(N,wc);wk=0:pi/512:pi;Hz=freqz(Bz,Az,wk);subplot(2,2,4);plot(wk/pi,20*log10(abs(Hz);grid on;xlabel(omega/pi);ylabel(幅度(dB);axis(0,1,-100,5);title(b); 二;x=-4,-2,0,-4,-6,-4,-2,-4,-6,-6,-4,-4,-6,-6,-2,6,12,8,0,-16,-38,-60,-84,-90,-66,-32,-4,-2,-4,8,12,12,10,6,6,6,4,0,0,0,0,0,-2,-4,0,0,0,-2,-2,0,0,-2,-2,-2,-2,0;subplot(2,2,1);n=0:55;stem(n,x,.);xlabel(n);ylabel(x(n);title(x(n)的脈沖響應);A=0.09036;b1=A,2*A,A;a1=1,-1.2686,0.7051;h1=filter(b1,a1,x);H1,w=freqz(b1,a1,100);b2=A,2*A,A;a2=1,-1.0106,0.3583;h2=filter(b2,a2,h1);H2,w=freqz(b2,a2,100);b3=A,2*A,A;a3=1,-0.9044,0.2155;h3=filter(b3,a3,h2);H3,w=freqz(b3,a3,100);subplot(2,2,2);stem(n,h3,.);xlabel(n);ylabel(y(n);title(通過濾波器H1(z),H2(z),H3(z)后的y3(n)函數(shù));subplot(2,2,3);H4=H1.*(H2);H=H4.*(H3);mag=abs(H);db=20*log10(mag+eps)/max(mag);plot(w/pi,db);xlabel(/);ylabel(20logHa3(ejw);title(通過濾波器H1(z),H2(z),H3(z)后的對數(shù)頻率響應20logHa3(ejw)函數(shù));grid;figure(2);N=1024;n=0:N/2-1;Xk=fft(x,N);AXk=abs(Xk(1:N/2);f=(0:N/2-1)*Fs/N;f=f/Fs;subplot(211);plot(f,AXk);title(x(n)的頻譜);xlabel(f);ylabel(| X(k) |);axis(0,0.5,0,400);Yk=fft(y,N);AYk=abs(Yk(1:N/2);subplot(212);plot(f,AYk);title(y(n)的頻譜);xlabel(f);ylabel(| Y(k) |);axis(0,0.5,0,400)x=-4,-2,0,-4,-6,-4,-2,-4,-6,-6,-4,-4,-6,-6,-2,6,12,8,0,-16,-38,-60,-84,-90,-66,-32,-4,-2,-4,8,12,12,10,6,6,6,4,0,0,0,0,0,-2,-4,0,0,0,-2,-2,0,0,-2,-2,-2,-2,0;subplot(2,2,1);n=0:55;stem(n,x,.);xlabel(n);ylabel(x(n);title(x(n)的脈沖響應);A=0.09036;b1=A,2*A,A;a1=1,-1.2686,0.7051;h1=filter(b1,a1,x);H1,w=freqz(b1,a1,100);b2=A,2*A,A;a2=1,-1.0106,0.3583;h2=filter(b2,a2,h1);H2,w=freqz(b2,a2,100);b3=A,2*A,A;a3=1,-0.9044,0.2155;h3=filter(b3,a3,h2);H3,w=freqz(b3,a3,100);subplot(2,2,2);stem(n,h3,.);xlabel(n);ylabel(y(n);title(通過濾波器H1(z),H2(z),H3(z)后的y3(n)函數(shù));subplot(2,2,3);H4=H1.*(H2);H=H4.*(H3);mag=abs(H);db=20*log10(mag+eps)/max(mag);plot(w/pi,db);xlabel(/);ylabel(20logHa3(ejw);title(通過濾波器H1(z),H2(z),H3(z)后的對數(shù)頻率響應20logHa3(ejw)函數(shù));grid;%x(n)的心電脈沖函數(shù)x=-4,-2,0,-4,-6,-4,-2,-4,-6,-6,-4,-4,-6,-6,-2,6,12,8,0,-16,-38,-60,-84, -90,-66,-32,-4,-2,-4,8,12,12,10,6,6,6,4,0,0,0,0,0,-2,-4,0,0,0,-2,-2,0,0,-2,-2,-2,-2,0subplot(2,2,1);n=0:55;stem(n,x,.);xlabel(n);ylabel(x(n);title(x(n)的心電脈沖函數(shù));%通過濾波器H1(z)后的y1(n)函數(shù)A=0.09036;b1=A,2*A,A;a1=1,-1.2686,0.7051;h1=filter(b1,a1,x);H1,w=freqz(b1,a1,100);%通過濾波器H1(z),H2(Z)后的y2(n)函數(shù)b2=A,2*A,A;a2=1,-1.0106,0.3583;h2=filter(b2,a2,h1);H2,w=freqz(b2,a2,100);%通過濾波器H1(z),H2(Z),H3(Z)后的y3(n)函數(shù)b3=A,2*A,A;a3=1,-0.9044,0.2155;h3=filter(b3,a3,h2);H3,w=freqz(b3,a3,100);subplot(2,2,2);stem(n,h3,.);xlabel(n);ylabel(y(n);title(通過濾波器H1(Z),H2(Z),H3(Z)后的y3(n)函數(shù));subplot(2,2,3);H4=H1.*(H2);H=H4.*(H3);mag=abs(H);db=20*log10(mag+eps)/max(mag);plot(w/pi,db);xlabel(w/pi);ylabel(20logHa3(ejw);title(通過濾波器H1(z)、H2(z)、H3(z)后的對數(shù)頻率響應20logHa3(ejw)函數(shù));grid;