【正文】
=freqz(b,1,fs)。plot(f*fs/(2*pi),20*log10(abs(h)))xlabel(39。頻率/赫茲39。)。ylabel(39。增益/分貝39。)。title(39。濾波器的增益響應39。)。figure(2)subplot(211)t=(1:100)/fs。s=sin(2*pi*200*t)+sin(2*pi*500*t)+sin(2*pi*800*t)+sin(2*pi*750*t)。%混和正弦波信號。plot(t,s)。%濾波前的信號圖像;xlabel(39。時間/秒39。)。ylabel(39。幅度39。)。title(39。信號濾波前時域圖39。)。subplot(212)Fs=fft(s,512)。 %將信號變換到頻域AFs=abs(Fs)。 %信號頻域圖的幅值f=(0:255)*fs/512。 %頻率采樣plot(f,AFs(1:256))。 %濾波前的信號頻域圖xlabel(39。頻率/赫茲39。)。ylabel(39。幅度39。)。title(39。信號濾波前頻域圖39。)。figure(3)sf=filter(b,1,s)。 %對信號s進行濾波;subplot(211)plot(t,sf)%濾波后的信號圖像;xlabel(39。時間/秒39。)。ylabel(39。幅度39。)。title(39。信號濾波前時域圖39。)。subplot(212)Fsf=fft(sf,512)。 %濾波后的信號頻域圖AFsf=abs(Fsf)。 %信號頻域圖的幅值f=(0:255)*fs/512。 %頻率采樣plot(f,AFsf(1:256)) %濾波后的信號頻域圖xlabel(39。頻率/赫茲39。)。ylabel(39。幅度39。)。title(39。信號濾波后頻域圖39。)。附錄三:采用II型線性相位,頻率采樣濾波器設計的低通濾波器M=27。 Wp=*pi。 %所需頻率采樣點個數(shù)及通帶截止頻率m=0:(M1)/2。 Wm=2*pi*m./(M1)。 %通頻帶上的采樣點及采樣點頻率mr=floor(Wp*(M1)/(2*pi))+2。 %向負方向入floor()=3。floor()=4;AD=[Wm=Wp]。AD(mr)=。Hd=AD.*exp(j**M*Wm)。 %構造頻域采樣向量H(k)Hd=[Hd conj(fliplr(Hd(2:(M+1)/2)))]。%fliplr函數(shù)實現(xiàn)矩陣的左右翻轉conj是求復數(shù)的共軛h=real(ifft(Hd))。%h(n)=IDFT[H(k)]w=linspace(0,pi,1000)。 %用于產(chǎn)生0,pi之間的1000點行矢量H=freqz(h,[1],w)。 %濾波器的幅頻特性圖figure(1)plot(w/pi,20*log10(abs(H)))。 %參數(shù)分別是歸一化頻率與幅值xlabel(39。歸一化角頻率39。)。ylabel(39。增益/分貝39。)。title(39。濾波器的增益響應39。)。axis([0 1 50 ])。figure(2)subplot(211)fs=2000。t=0:1/fs:。 %定義時間范圍和步長s=sin(2*pi*100*t)+sin(2*pi*300*t)+sin(2*pi*700*t)。 %濾波前信號plot(t,s)。 %濾波前的信號圖像xlabel(39。時間/秒39。)。ylabel(39。幅度39。)。title(39。信號濾波前時域圖39。)。subplot(212)Fs=fft(s,512)。 AFs=abs(Fs)。 %將信號變換到頻域及信號頻域圖的幅值f=(0:255)*fs/512。 %頻率采樣plot(f,AFs(1:256))。 %濾波前的信號頻域圖xlabel(39。頻率/赫茲39。)。ylabel(39。幅度39。)。title(39。信號濾波前頻域圖39。)。figure(3)sf=filter(h,1,s)。 %使用filter函數(shù)對信號進行濾波subplot(211)plot(t,sf) %濾波后的信號圖像xlabel(39。時間/秒39。)。ylabel(39。幅度39。)。title(39。信號濾波后時域圖39。)。axis([ 2 2])。 %限定圖像坐標范圍subplot(212)Fsf=fft(sf,512)。 AFsf=abs(Fsf)。 %濾波后的信號頻域圖及信號頻域圖的幅值f=(0:255)*fs/512。 %頻率采樣plot(f,AFsf(1:256)) %濾波后的信號頻域圖xlabel(39。頻率/赫茲39。)。ylabel(39。幅度39。)。title(39。信號濾波后頻域圖39。)。附錄四:頻率采樣濾波器設計的高通濾波器n=50。f=[0,1]。a=[0,0,1]。b=fir2(n,f,a)。freqz(b)附錄五:最優(yōu)等波紋線性相位FIR低通濾波器wp=*pi。ws=*pi。deltap=。deltas=。 wm=wswp。M=ceil((10*log10(deltap*deltas)13)/(*wm))。F=[0,wp,ws,pi]/pi。Ad=[1,1,0,0]。K=deltap/deltas。W=[1/K,1]。 [h,err,res]=firpm(M,F,Ad,W)。 [H,W]=freqz(h,1)。L=M/2。n=0:M。a=[h(L+1),2*h(L:1:1)]。 k=[0:1:L]。W1=[0:1:511]39。*pi/512。A=cos(W1*k)*a39。 figure subplot(2,1,1) stem(n,h,39。fill39。,39。MarkerSize39。,2)axis([0,M,])xlabel(39。n 39。)。ylabel(39。h(n)39。)。title(39。沖激響應39。)。 subplot(2,1,2)plot(W/pi,A)。 axis([0,1,])xlabel(39。頻率/(w/pi) 39。)。ylabel(39。幅度/H(e^jw)39。)。title(39。幅度響應圖39。)。figure plot(W/pi,20*log10(abs(H)))axis([0,1,100,10])xlabel(39。w/pi39。)。ylabel(39。幅度增益/dB)39。)。title(39。對數(shù)幅度響應圖39。)。 figureplot(,)axis([0,1,])xlabel(39。頻率/(w/pi) 39。)。ylabel(39。E(w)39。)。title(39。誤差逼近39。)。附錄外文資料原文The simulation and the realization of the digital filterLv Tiejun,Guo Shuangbing,Xiao XianciThe first chapter figures UnitonIn signal processing, the function of a filter is to remove unwanted parts of the signal, such as random noise, or to extract useful parts of the signal, such as the ponents lying within a certain frequency range. There are two main kinds of filter, analog and digital. They are quite different in their physical makeup and in how they work. An analog filter uses analog electronic circuits made up from ponents such as resistors, capacitors and opamps to produce the required filtering effect. Such filter circuits are widely used in such applications as noise reduction, video signal enhancement, graphic equalisers in hifi systems, and many other areas. There are wellestablished standard techniques for designing an analog filter circuit for a given requirement. At all stages, the signal being filtered is an electrical voltage or current which is the direct analogue of the physical quantity (. a sound or video signal or transducer output) involved. A digital filter uses a digital processor to perform numerical calculations on sampled values of the signal. The processor may be a generalpurpose puter such as a PC, or a specialised DSP (Digital Signal Processor) chip. The analog input signal must first be sampled and digitised using an ADC (analog to digital converter). The resulting binary numbers, representing successive sampled values of the input signal, are transferred to the processor, which carries out numerical calculations on them. These calculations typically involve multiplying the input values by constants and adding the products together. If necessary, the results of these calculations, which now represent sampled values of the filtered signal, are output through a DAC (digital to analog converter) to convert the signal back to analog form.Unit refers to the input signals used to filter hardware or software. If the filter input, output signals are separated, they are bound to respond to the impact of the Unit is separated, such as digital filters filter definition. Digital filter function, which was to import sequences X transformation into export operations through a series Y.According to figures filter function 24hour live response characteristics, digital filters can be divided into two, namely, unlimited long live long live the corresponding IIR filter and the limited response to FIR filters. IIR filters have the advantage of the digital filter design can use simulation results, and simulation filter design of a