University of Kentucky: EE 422G - Signals and Systems Laboratory
University of Kentucky: EE 422G - Signals and Systems Laboratory
Objectives:
Use filter design and analysis tools to create FIR filters based on general filter
specification.
Create a simulation with Simulink.
1. Background
Digital filters are used in a wide variety of signal processing applications, such as
spectrum analysis, digital image processing, and pattern recognition. Digital filters
eliminate a number of problems associated with their classical analog counterparts and
thus are often used in place of analog filters. Digital filters belong to the class of discrete-
time LTI (linear time invariant) systems, which are characterized by the properties of
causality, recursibility, and stability. They can be characterized in the time domain by
their unit-impulse response and in the transform domain by their transfer function. A
unit-impulse response sequence of a causal LTI system could be of either finite or infinite
duration and this property determines their classification into either finite impulse
response (FIR) or infinite impulse response (IIR) system. To illustrate this, we consider
the most general case of a discrete time LTI system with the input sequence denoted by
x(kT) and the resulting output sequence y(kT) given by:
If at least one denominator coefficient a v is not zero, then system is recursive; its
impulse response is of infinite duration (IIR system). If all denominator coefficients are
zero, the corresponding system is non-recursive (FIR system); its impulse response is of
finite duration and the transfer function H(z) is a simple polynomial. Commonly, b is
called the th forward filter coefficient and a v the v th feedback or reverse filter
coefficient.
In this lab you will design FIR filter using 2 methods – windowing and the Parks-
McClellan algorithm.
2. Pre-Lab
1. For the window functions listed below, write a script to plot each window
function on the same graph (use different line styles for each window function).
Create another graph and plot its DFT magnitude on a linear scale, and finally
create another graph and plot its DFT magnitude on a dB scale.
a. boxcar
b. triangular
c. hamming
Comment on how the general window shape (steepness of taper) affects the
spectral magnitude (impact on width of main lode and height of sidelobes)
2. Repeat number 1 for a Kaiser window of length 128 and with values of 4, 6, and
9.
3. For a sampling rate of 48kHz design an order-40 low-pass filter having cut-off
frequency 10kHz by windowing method. In your design, use Hamming window
as the windowing function (see help on fir1). Use the freqz command to plot the
filter’s magnitude response (in dB) and use the filter command to plot the impulse
response.
4. For a sampling rate of 48kHz, design an order-40 low-pass filter having transition
band between 9kHz and 11kHz using the Parks-McClellan FIR filter design
algorithm (see help on firpm). Use the freqz command to plot the filter’s
magnitude response (in dB) and use the filter command to plot the impulse
response.
3. In-Lab exercise
a. rectangular (boxcar)
b. triangular (triang)
c. Hamming (hamming)
On a single graph plot the all the impulse responses, on another graph plot all the
magnitude responses, and then in individual graphs plot the zero-pole locations of
the 3 filters. In the discussion section compare impact of the window on the filter
characteristics. Refer to the window plots of the prelab and make a general
statement about window characteristics and their impact on the filter
characteristics.
2. Repeat Exercise 1 for a 15th order filter. Comment on the impact of filter order.
3. Repeat Exercise 1 for a length-32 linear-phase FIR low-pass filter using a Kaiser
window with = 4, 6, and 9 and pass-band cut off of 6kHz. Plot the impulse
response, magnitude response, and zero-pole locations. Compare the
characteristics of the magnitude response with each other and with the filters from
the first exercise. Discuss how the trade-off between transition bandwidth and
ripple varies with ?
With the FIR windowing method, design a 16 order Bandstop filter with stop-band
between 1500 Hz and 2500 Hz using hamming window. Plot the magnitude of the
frequency response of the filter. Is this what you expected? Apply the filter to the input
signal (x), and plot the spectrum magnitude of the input and output signal on the same
figure. Is this output as expected? For spectrum plot the follow code is helpful:
Nfft = 2*length(x);
xfftmag=(abs(fft(x,Nfft))); %Compute spectrum of input signal.
xfftmagh=xfftmag(1:length(xfftmag)/2);
%Plot only the first half of FFT, since second half is mirror image
%the first half represents the positive frequencies from
%0 to Fs/2, the Nyquist sampling limit.
f=[1:length(xfftmagh)]*Fs/Ns; %Make freq array that varies from
%0 Hz to Fs/2 Hz.
plot(f,xfftmagh,’:k’); %Plot frequency spectrum of input signal
%( Now you can hold the figure and repeat for the output signal,
% use a different line style)