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 + FIR filter desigen

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
Hi,

I'm simulatin a lecture in FIR filter desigening

I'm to desigen the filter (not using filters in matlab)

the desigen scheme is iterative in witch each iteration requires 2 FFT computations.

any way, I need an initial estimate & the lecture uses the ideal filter (LP)(rectangular) . I use the fir2... function in order to compute the initial valuse

problem arises when I put this filter in a matrix indice
because for example filter has 30 cofficients but h(1) must be scaler.

%Equiripple FIR Filter Desigen by the FFT Algorithm
close all,clc;
deltap = 0.05;
deltas = 0.05;
wp = .4*pi;
ws = .6*pi;
N=3;
I=[-N:N];

f = [0 0.4 0.6 1]; m = [1 1 0 0];
b = fir2(30,f,m);
[h,w] = freqz(b,.5,512);
plot(f,m,w/pi,abs(h))
legend('Ideal','fir2 Designed')
title('Comparison of Frequency Response Magnitudes')

figure
plot(b)
h(1)=b;
H(2)=abs(h)
if H(2)> b+.05 G(2)=b + .05
elseif H(2)< b-.05 G(2)=b - .05
else G(2)=H(2)
end
g(2)=ifft(G(2))
for i=-N:N
if -N<=i<=N h(3)=g(2)
else h(3)=0
end
end

%hold on
for k=1:4
if (h(k+1)-h(k))>.05
H(K)= fft(h(k))
if H(k)> b+.05 G(k)=b + .05
elseif H(k)< b-.05 G(k)=b - .05
else G(k)=H(k)
end
g(k)=ifft(G(k))
for i=-N:N
if -N<=i<=N h(k+1)=g(k)
else h(k+1)=0
end
end
end
end
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top