300 likes | 440 Views
OT3OS1. 20.12.2007. Metode projektovanja FIR filtara. Specifikacije za amplitudsku karakteristiku. Projektovanje primenom prozora. MATLAB Naredba FIR1 N=16; n=[0:N]'; f6dB=100; f0=1000; wn=f6dB/(f0/2); h= fir1 (N,wn); figure,stem(n,h),xlabel('n'),ylabel('h(n)');
E N D
OT3OS1 20.12.2007.
Projektovanje primenom prozora MATLAB Naredba FIR1 N=16; n=[0:N]'; f6dB=100; f0=1000; wn=f6dB/(f0/2); h=fir1(N,wn); figure,stem(n,h),xlabel('n'),ylabel('h(n)'); [H,w]=freqz(h,1,1000,f0); figure,plot(w,20*log10(abs(H))),xlabel('f[Hz]'),ylabel('|H(e^j^\omega)| [dB]'); line([0 f0/2],[-6 -6],'color',[0 0 0]); line([f6dB f6dB],[-50 0],'color',[0 0 0]); z=roots(h); p=zeros(size(z)); figure,zplane(z,p);
Uticaj prozora N=32; n=[0:N]'; fp=100; f0=1000; wn=fp/(f0/2); h1=fir1(N,wn,rectwin(N+1)); h2=fir1(N,wn,hamming(N+1)); h3=fir1(N,wn,blackman(N+1)); figure,stem(n,[h1;h2;h3]'),xlabel('n'),ylabel('h(n)'); [H1,w]=freqz(h1,1,1000,f0); [H2,w]=freqz(h2,1,1000,f0); [H3,w]=freqz(h3,1,1000,f0); figure,plot(w,20*log10([abs(H1) abs(H2) abs(H3)])), xlabel('f [Hz]'),ylabel('|H(e^j^\omega)| [dB]');
Red LP filtra N1=32; N2=33; n=[0:N2]'; fp=100; f0=1000; wn=fp/(f0/2); h1=fir1(N1,wn); h1(N2+1)=0; h2=fir1(N2,wn); figure,stem(n,[h1;h2]'),xlabel('n'),ylabel('h(n)'); [H1,w]=freqz(h1,1,1000,f0); [H2,w]=freqz(h2,1,1000,f0); figure,plot(w,20*log10([abs(H1) abs(H2)])), xlabel('f [Hz]'),ylabel('|H(e^j^\omega)| [dB]'); [g1,w]=grpdelay(h1,1,1000,f0); [g2,w]=grpdelay(h2,1,1000,f0); figure,plot(w,[g1 g2]),xlabel('f [Hz]'),ylabel('gd'),ylim([15 17]);
Red HP filtra N1=32; N2=33; fp=100; f0=1000; wn=fp/(f0/2); h1=fir1(N1,wn,'high'); h2=fir1(N2,wn,'high'); h1(length(h2))=0; n=[0:length(h2)-1]'; figure,stem(n,[h1;h2]'),xlabel('n'),ylabel('h(n)'); [H1,w]=freqz(h1,1,1000,f0); [H2,w]=freqz(h2,1,1000,f0); figure,plot(w,20*log10([abs(H1) abs(H2)])), xlabel('f [Hz]'),ylabel('|H(e^j^\omega)| [dB]'); [g1,w]=grpdelay(h1,1,1000,f0); [g2,w]=grpdelay(h2,1,1000,f0); figure,plot(w,[g1 g2]),xlabel('f [Hz]'),ylabel('gd'),ylim([15 17.5]);
Rešenje1 Warning: Odd order symmetric FIR filters must have a gain of zero at the Nyquist frequency. The order is being increased by one.
Projektovanje zasnovano na frekvencijskom odabiranju MATLAB Naredba FIR2 N=32;f6dB=100;f0=1000; wn=f6dB/(f0/2); h1=fir1(N,wn); h2=fir2(N,[0 wn 1],[1 0.5 0]); h3=fir2(N,[0 wn wn 1],[1 1 0 0]); n=[0:N]'; figure,stem(n,[h1;h2;h3]'),xlabel('n'),ylabel('h(n)'),; [H1,w]=freqz(h1,1,1000,f0); [H2,w]=freqz(h2,1,1000,f0); [H3,w]=freqz(h3,1,1000,f0); figure,plot(w,20*log10([abs(H1) abs(H2) abs(H3)])), xlabel('f [Hz]'),ylabel('|H(e^j^\omega)| [dB]'); z1=roots(h1);p1=zeros(size(z1)); z2=roots(h2);p2=zeros(size(z2)); z3=roots(h3);p3=zeros(size(z3)); figure,zplane([z1 z2 z3],[p1 p2 p3]);
Optimalna aproksimacija MATLAB Naredba FIRPM N=32; fg=[0 100 200 500]; f0=1000; wg=fg/(f0/2); h1=fir2(N,wg,[1 1 0 0]); h2=firpm(N,wg,[1 1 0 0]); n=[0:N]'; figure,stem(n,[h1;h2]'),xlabel('n'),ylabel('h(n)'); [H1,w]=freqz(h1,1,1000,f0); [H2,w]=freqz(h2,1,1000,f0); figure,plot(w,20*log10([abs(H1) abs(H2)])), xlabel('f[Hz]'),ylabel('|H(e^j^\omega)|[dB]'); figure,plot(w,[abs(H1) abs(H2)]),xlabel('f[Hz]'),ylabel('|H(e^j^\omega)|'); z1=roots(h1);p1=zeros(size(z1)); z2=roots(h2);p2=zeros(size(z2)); figure,zplane([z1 z2],[p1p2]);
Red HP filtra N1=32; N2=33; fg=[0 100 200 500]; f0=1000; wg=fg/(f0/2); h1=firpm(N1,wg,[0 0 1 1]); h2=firpm(N2,wg,[0 0 1 1]); h3=firpm(N2,wg,[0 0 1 1],'h'); n=[0:length(h2)-1]'; figure,stem(n,[h1 0 0;h2;h3 0]'),xlabel('n'),ylabel('h(n)'); [H1,w]=freqz(h1,1,1000,f0); [H2,w]=freqz(h2,1,1000,f0); [H3,w]=freqz(h3,1,1000,f0); figure,plot(w,20*log10([abs(H1) abs(H2) abs(H3)])), xlabel('f [Hz]'),ylabel('|H(e^j^\omega)| [dB]'); [g1,w]=grpdelay(h1,1,1000,f0); [g2,w]=grpdelay(h2,1,1000,f0); [g3,w]=grpdelay(h3,1,1000,f0); figure,plot(w,[g1 g2 g3]),xlabel('f [Hz]'),ylabel('gd'),ylim([15 18]),;
Rešenje1 Warning: Odd order symmetric FIR filters must have a gain of zero at the Nyquist frequency. The order is being increased by one. Alternatively, you can pass a trailing 'h' argument, as in firpm(N,F,A,W,'h'), to design a type 4 linear phase filter.