Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Lab5

The document outlines Lab 5 for ELG4177 - Digital Signal Processing, focusing on FIR filter design using two methods: frequency sampling and window functions. It includes detailed instructions for designing FIR filters, analyzing their impulse and frequency responses, and comparing different window techniques. Additionally, it provides hints and MATLAB code snippets for practical implementation and analysis of the filters designed.

Uploaded by

waleed ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lab5

The document outlines Lab 5 for ELG4177 - Digital Signal Processing, focusing on FIR filter design using two methods: frequency sampling and window functions. It includes detailed instructions for designing FIR filters, analyzing their impulse and frequency responses, and comparing different window techniques. Additionally, it provides hints and MATLAB code snippets for practical implementation and analysis of the filters designed.

Uploaded by

waleed ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

ELG4177 - DIGITAL SIGNAL PROCESSING

Lab5

By:Hitham Jleed

http://www.site.uottawa.ca/~hjlee103/
© H. Jleed: 2018 ~
Assignment 05

FIR FILTER DESIGN

© H. Jleed: 2018 ~
There two methods for FIR Design

• (A) Design with frequency sampling


• (B) Design with window functions

© H. Jleed: 2018 ~
Part # A FIR filter design

© H. Jleed: 2018 ~
Part # A
OPTIMUM APPROXIMATIONS OF FIR FILTERS

© H. Jleed: 2018 ~
Part # A

▪ The main lobe as narrow as possible.


▪ The problem is not the height of the side lobes. The matter is
how you accumulate the area as you integrate through it.

© 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 ?

It should look like this


Part # A Illustration of (f) &(g)
(f)From a), d), and e), what is the effect of M and why should it be set to M=(len-1)/2 ?

(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.

Hint: [See slide #6]


Plot Z-plane to clarify which type the filter is

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, '-.');

The simple way:


zplane(h,[1])

The ideal Filter:


Ad=[ones(1,pass_len),zeros(1,len-2*pass_len+1),-1*ones(1,pass_len-1)]; % Must use negative !!!

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

Solution to Sharp Discontinuity of Rectangular Window ➔ use Other windows.


Windows with no abrupt discontinuity can be used to reduce Gibbs oscillations
(e.g. Hanning, Hamming, Blackman)
Part # B
h) Design a length-23 linear-phase FIR low-pass filter with a passband edge of  0 = 0.3.
radians/sample using a window approach. Do not use a frequency sampling technique as
in a). Use the windowing approach with the following windows: rectangular, Hanning,
Hamming and Kaiser with  = 6 Find the frequency response of the resulting filters,
and compare with the filter found in a).

The cut-off frequency “wn” must be


normalized between 0 < Wn < 1.0,
wo=0.3*pi; % Passband edge
len=23;M=len-1; % order=length-1
wn=wo/pi;
h = fir1(M,wn,rectwin(M+1));

© 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

firpm is a new version function of remez


firpmord is a new version function of remezord

Hint: see this example.


https://www.mathworks.com/help/signal/ug/fir-filter-design.html
© H. Jleed: 2018 ~
Part # B Modulation of filters
j) Transform one of the low-pass filters that you have designed in this assignment
to a band-pass filter. Hint : use the frequency shifting property or the modulation
property of the Fourier transform.
hBP [n] = h[n].e jn use:  =  /2

© H. Jleed: 2018 ~
Part # B Extra

Compute FIR Order


dev = [ p  s ];
f = [fp fc];
a = [1 0];
[n,fo,ao,w] = firpmord(f, a, dev, fs);

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 ~

You might also like