Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Matlab code for FIR filter design

Status
Not open for further replies.

speech

Newbie level 5
Joined
Apr 14, 2007
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,340
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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top