【文章內(nèi)容簡介】
+1)end % Use()to get Beta if As 50 BTA = *()。elseif As = 21 BTA = *(As21)^+*(As21)。else BTA = 0。end Win = kaiser(N+1,BTA)。h = fir1(N,Wn,Win)。% Show the Numerator Coefficients disp(39。Numerator Coefficients are 39。)。disp(h)。% Compute and plot the gain response [g, w] = gain(h,[1])。figure(1)。plot(w/pi,g)。grid。axis([0 180 5])。xlabel(39。omega /pi39。)。ylabel(39。Gain in dB39。)。title(39。Gain Response39。)。% Compute the frequency response w2 = 0:pi/511:pi。Hz = freqz(h,[1],w2)。% Find and plot the phase figure(2)。Phase = angle(Hz)。plot(w2/pi,Phase)。grid。xlabel(39。omega /pi39。)。ylabel(39。Phase(rad)39。)。title(39。Phase Response39。)。figure(3)。UPhase = unwrap(Phase)。plot(w2/pi,UPhase)。grid。xlabel(39。omega /pi39。)。ylabel(39。Unwrapped Phase(rad)39。)。title(39。Unwrapped Phase Response39。)。低通濾波器系數(shù): 增益和相位響應(yīng)如下:從圖中可以看出設(shè)計(jì)的濾波器滿足要求。N= 程序:% Use Kaiser window to design a linear phase Lowpass % FIR Digital Filter meeting the design specification given % in kaiserord and fir1.%Compute and plot the gain function.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear。% Design spec as given in = 。Ws = 。As = 50。Ds = 10^(As/20)。% Design the Filter F = [Wp Ws]。A = [1 0]。DEV = [Ds Ds]。[N,Wn,BTA,Ftype] = kaiserord(F,A,DEV)。Win = kaiser(N+1,BTA)。h = fir1(N,Wn,Ftype,Win)。% Show the Numerator Coefficients disp(39。Numerator Coefficients are 39。)。disp(h)。% Compute and plot the gain response [g, w] = gain(h,[1])。figure(1)。plot(w/pi,g)。grid。axis([0 180 5])。xlabel(39。omega /pi39。)。ylabel(39。Gain in dB39。)。title(39。Gain Response39。)。% Compute the frequency response w2 = 0:pi/511:pi。Hz = freqz(h,[1],w2)。% Find and plot the phase figure(2)。Phase = angle(Hz)。plot(w2/pi,Phase)。grid。xlabel(39。omega /pi39。)。ylabel(39。Phase(rad)39。)。title(39。Phase Response39。)。figure(3)。UPhase = unwrap(Phase)。plot(w2/pi,UPhase)。grid。xlabel(39。omega /pi39。)。ylabel(39。Unwrapped Phase(rad)39。)。title(39。Unwrapped Phase Response39。)。參數(shù)如下:Wp = 。Ws = 。As = 50 dB增益和相位響應(yīng)如下:從圖中可以看出設(shè)計(jì)的濾波器滿足要求。N= 用fir2設(shè)計(jì)一個(gè)95階有限沖激響應(yīng)濾波器。程序:% Program Q7_25 % Use fir2 to design a linear phase Lowpass % FIR Digital Filter meeting the design specification given % in .%Print out the numerator coefficients % for the transfer function.%Compute and plot the gain function.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear。% Design spec as given in = [1200 1800 3600 4200]。A = [0 1 0]。DEV = [ ]。Fs = 12000。Dp = 。Ds = 。[N,Wn,BTA,FILTYPE] = kaiserord(F,A,DEV,Fs)。N % firpm setup F2 = 2*[0 1200 1800 3600 4200 6000]/Fs。A2 = [0 0 1 1 0 0]。wgts = max(Dp,Ds)*[1/Ds 1/Dp 1/Ds]。h = firpm(N,F2,A2,wgts)。% Show the Numerator Coefficients disp(39。Numerator Coefficients are 39。)。disp(h)。% Compute and plot the gain response [g, w] = gain(h,[1])。figure(1)。plot(w/pi,g)。grid。axis([0 180 5])。xlabel(39。omega /pi39。)。ylabel(39。Gain in dB39。)。title(39。Gain Response39。)。% Compute the frequency response w2 = 0:pi/511:pi。Hz = freqz(h,[1],w2)。% Find and plot the phase figure(2)。Phase = angle(Hz)。plot(w2/pi,Phase)。grid。xlabel(39。omega /pi39。)。ylabel(39。Phase(rad)39。)。title(39。Phase Response39。)。figure(3)。UPhase = unwrap(Phase)。plot(w2/pi,UPhase)。grid。xlabel(39。omega /pi39。)。ylabel(39。Unwrapped Phase(rad)39。)。title(39。Unwrapped Phase Response39。)。增益響應(yīng): 相位響應(yīng):從增益響應(yīng)的圖像中可以看出,此濾波器滿足指標(biāo)。N= 用remez設(shè)計(jì)具有如下指標(biāo)的有限沖激響應(yīng)帶通濾波器。程序:% Program Q7_27 % Use kaiserord and firpm to design the linear phase bandpass % FIR Digital Filter specified in .% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear。% Design spec as given in = 1500。Fp1 = 1800。Fp2 = 3000。Fs2 = 4200。Fs = 12000。Dp = 。Ds = 。F = [Fs1 Fp1 Fp2 Fs2]。A = [0 1 0]。DEV = [Ds Dp Ds]。[N,Wn,BTA,FILTYPE] = kaiserord(F,A,DEV,Fs)。% firpm setup ws1 = 2*Fs1/Fs。wp1 = 2*Fp1/Fs。wp2 = 2*Fp2/Fs。ws2 = 2*Fs2/Fs。F2 = [0 ws1 wp1 wp2 ws2 1]。A2 = [0 0 1 1 0 0]。wgts = max(Dp,Ds)*[1/Ds 1/Dp 1/Ds]。h = firpm(N,F2,A2,wgts)。% Show the Numerator Coefficients disp(39。Numerator Coefficients are 39。)。disp(h)。% Compute and plot the gain response [g, w] = gain(h,[1])。figure(1)。plot(w/pi,g)。grid。axis([0 180 5])。xlabel(39。omega /pi39。)。ylabel(39。Gain in dB39。)。title(39。Gain Response39。)。% Compute the frequency response w2 = 0:pi/511:pi。Hz = freqz(h,[1],w2)。% Find and plot the phase figure(2)。Phase = angle(Hz)。plot(w2/pi,Phase)。grid。xlabel(39。omega /pi39。)。ylabel(39。Phase(rad)39。)。title(39。Phase Response39。)。figure(3)。UPhase = unwrap(Phase)。plot(w2/pi,UPhase)。grid。xlabel(39。omega /pi39。)。ylabel(39。Unwrapped Phase(rad)39。)。title(39。Unwrapped Phase Response39。)。figure(4)。% Add lines to the plot to help determine if the spec was on。tmpY = 0::。tmpX = ones(1,length(tmpY))*wp1。plot(tmpX,tmpY, 39。r39。)。% vertical line at passband edge freq tmpX = ones(1,length(tmpY))*wp2。plot(tmpX,tmpY, 39。r39。)。% vertical line at passband edge freq tmpX = ones(1,length(tmpY))*ws1。plot(tmpX,tmpY, 39。g39。)。% vertical line at stopband edge freq tmpX = ones(1,length(tmpY))*ws2。plot(tmpX,tmpY, 39。g39。)。% vertical line at stopband edge freq tmpY = ones(1,length(w))*(Dp)。plot(w/pi,tmpY, 39。r39。)。% horizontal line at Dp tmpY = ones(1,length(w))*(Ds)。plot(w/pi,tmpY, 39。g39。)。% horizontal line at Ds % now plot the Frequency Response plot(w2/pi,abs(Hz))。grid。hold off。增益響應(yīng):從增益響應(yīng)的圖像可以看出,該濾波器不滿足設(shè)計(jì)指標(biāo)。用kaiserord估計(jì)濾波器的階數(shù)N=73。第三篇:數(shù)字信號(hào)處理第六章介紹第六章數(shù)字濾波器結(jié)構(gòu):級(jí)聯(lián)的實(shí)現(xiàn)num = input(39。分子系數(shù)向量 = 39。)。den = input(39。分母系數(shù)向量 = 39。)。[z,p,k] = tf2zp(num,den)。sos = zp2sos(z,p,k),生成如下有限沖激響應(yīng)傳輸函數(shù)的一個(gè)級(jí)聯(lián)實(shí)現(xiàn): H1(z)=2+10z^(1)+23z^(2)+34z^(3)+31z^(4)+16 z^(5)+4z^(6)畫出級(jí)聯(lián)實(shí)現(xiàn)的框圖。H1(z)是一個(gè)線性相位傳輸函數(shù)嗎? 答:運(yùn)行結(jié)果:sos = zp2sos(z,p,k)Numerator coefficient vector = [2,10,23,34,31,16,4] Denominator coefficient vector = [1] sos = 0 0 0 0 0 0級(jí)聯(lián)框圖:H1(z)不是一個(gè)線性相位傳輸函數(shù),因?yàn)橄禂?shù)不對稱。,生成如下有限沖激響應(yīng)傳輸函數(shù)的一個(gè)級(jí)聯(lián)實(shí)現(xiàn): H2(z)=6+31z^(1)+74z^(2)+102z^(3)+74z^(4)+31 z^(5)+6z^(6)畫出級(jí)聯(lián)實(shí)現(xiàn)的框圖。H2(z)是一個(gè)線性相位傳輸函數(shù)嗎?只用4個(gè)乘法器生成H2(z)的一級(jí)聯(lián)實(shí)現(xiàn)。顯示新的級(jí)聯(lián)結(jié)構(gòu)的框圖。Numerator coefficient vector = [6,31,74,102,74,31,6] Denominator coefficient vector = [1] sos = 0 0 0 0 0 0 級(jí)聯(lián)框圖:H2(z)是一個(gè)線性相位傳輸函數(shù)。只用四個(gè)乘法器生成級(jí)聯(lián)框圖::級(jí)聯(lián)和并聯(lián)實(shí)現(xiàn): 畫出級(jí)聯(lián)實(shí)現(xiàn)的框圖。答:Numerator coefficient vector = [3,8,12,7,2,2] Denominator coefficient vector = [16,24,24,14,5,1] sos = 0 0 級(jí)聯(lián)實(shí)現(xiàn)框圖::畫出級(jí)聯(lián)實(shí)現(xiàn)的框圖。答:級(jí)聯(lián)實(shí)現(xiàn)框圖: num = input(39。分子系數(shù)向量 = 39。)。den = input(39。分母系數(shù)分量 = 39。