plot fir filter with matlab
my project is about FIR filter design by the FFT algorithm,
I have some problem in writing code in Matlab.
if any body could help me I'll really be tankful.
please copy paste this code in your Matlab software(ver.7) & run it.
f = [0 0.4 0.6 1]; m = [1 1 0 0];
h
,1) = fir2(31,f,m) ; %time domain FIR filter
plot(b);
hold on
plot(I,h
,1),'r');grid;
title('h0[n]','fontweight','bold');
xlabel('time');ylabel('amplitude');
[Hid,w] = freqz(b,1,64) ; %frequency domain
figure
plot(f,m,w/pi,abs(Hid));
legend('Ideal','fir2 Designed')
title('Comparison of Frequency Response Magnitudes,Hid(w)');
xlabel('frequency');ylabel('amplitude');grid;;
H
,1)=abs(fft(h
,1),512));
figure
w=-256:255;
u=w';
plot(u,H
,1));title('FFT')
Ed
)=.05;
for k=1:4
H
,k) =abs(fft(h
,k),512));
if H
,k)> (H
,1)+Ed
)) G
,k)=H
,1) + Ed
) ;
elseif H
,k)< (H
,1)-Ed
)) G
,k)=H
,1) - Ed
) ;
elseif (H
,1)-Ed
)) <= H
,k)<= (H
,1)+Ed
)) G
,k)=H
,k);
end
g
,k)=ifft( G
,k),32);
i=-N:N;
h
,(k+1))=g
,k) ;
%figure
%plot(i,h
,(k+1)))
delta=(h
,k+1)-h
,k));
%if delta>Ed
,1), break, end
end
the problem : Matlab computes G
,k) & that is equal to zero
BUT WHY?????????????????
I'll never forgot your help. thank you
my mail:
barg_ieee2@yahoo.com