Lab5
Lab5
Lab5
By:Hitham Jleed
http://www.site.uottawa.ca/~hjlee103/
© H. Jleed: 2018 ~
Assignment 05
© H. Jleed: 2018 ~
There two methods for FIR Design
© H. Jleed: 2018 ~
Part # A FIR filter design
© H. Jleed: 2018 ~
Part # A
OPTIMUM APPROXIMATIONS OF FIR FILTERS
© H. Jleed: 2018 ~
Part # A
© H. Jleed: 2018 ~
Part # A Illustration of (a) (b)&(c)
M=(len-1)/2; % Type 1
n Shifted by M
k=0:(len-1);
wo=0.3*pi; % Passband edge
len=23; % Length of filter pd=exp(2*pi*j*(-M)*k/len);
pass_len=fix(wo*len/(2*pi))+1; % Passband Hd=Ad.*pd;
length h=real(ifft(Hd));
Ad=[ones(1,pass_len),zeros(1,len- h2=imag(ifft(Hd));
2*pass_len+1),ones(1,pass_len-1)]; figure; stem(h);hold on;
stem((1:len)/len,Ad); stem(h2, 'r');
xlabel('normalized frequency');
legend('real','imaginary'); xlabel(‘n');
ylabel('Amplitude');
title('ideal filter')
© H. Jleed: 2018 ~
Part # A cont.
M=11
© H. Jleed: 2018 ~
Part # A
Illustration of (d) &(e)
(d) Design a 23 coeffs. FIR filter as in a) but this time with a phase response of zero (i.e pd=ones(1,len) ).
Find the resulting impulse response h[n], and the magnitude and phase frequency response of
this filter h[n]. Is h[n] symetrical/anti-symetrical ? How is the magnitude response ? Is the phase
response linear phase ? Why ?
(e) Design a 23 coeffs. FIR filter as in a) but this time with value of a M=5. Find the
resulting impulse response h[n], and the magnitude and phase frequency response
of this filter h[n]. Is h[n] symetrical/anti-symetrical ? How is the magnitude response ? Is
the phase response linear phase ?
(g) Now design an even length filter of length 22, using the same approach as in a). Find the resulting impulse response h[n], and the magnitude
and phase frequency response of this filter h[n]. Note that an symmetric even-length linear-phase FIR filter always have a zero at z=pi
Compare the amount of overshoot near the band edge with the design for len=23.
One way:
plot(roots(h),'o');
ang = linspace(0, 2*pi, 100); mag = ones(1,100);
[x y] = pol2cart(ang, mag);hold on; plot(x,y, '-.');
h=real(ifft(Hd))+1i.*imag(ifft(Hd));
© H. Jleed: 2018 ~
(Part B) Design with window functions
© H. Jleed: 2018 ~
Part # B Window Design Method
© H. Jleed: 2018 ~
Part # B
(i) Design a length-23 linear-phase FIR low-pass filter with a passband edge of
0 = 0.3 radians/sample and a stopband edge of 0 = 0.35 radians/sample, using the
remez/firpm Matlab function (you can also use the remezord/firpmord function).
What is the particular characteristic of the magnitude of the filter frequency response ?
How does the frequency response compare with the responses from b) and h) ?
N: is the filter order.
>>h = firpm(N,f,a) f: is a vector of pairs of normalized frequency points, specified in the range
between 0 and 1
a: is a vector containing the desired amplitudes at the points specified in f
f and a are the same length. This length must be an even number.
>> help firpm
>> help firpmord
© H. Jleed: 2018 ~
Part # B Extra
h = firpm(n,fo,ao,w);
fdatool
FDATool for window design The SP toolbox in
MATLAB contains a GUI-based tool for designing
FIR and IIR digital filters that makes designing them
a convenient and straightforward task. You can use
this tool to: Design filters, Analyze filters, and
Modify existing filter designs
© H. Jleed: 2018 ~
Finish the lab and submit your report
The END
© H. Jleed: 2018 ~