Homework 2
Homework 2
Evans
Homework #2
Homework submitted after 11:00am will be subject to a penalty of 2 points per minute late.
Reading: Johnson, Sethares and Klein, chapters 1, 2, 3 and 7, and Appendices A and F
This assignment is intended to continue our review of key concepts from Linear Systems and Signals,
and introduce the simulation and design of discrete-time linear time-invariant filters.
Here are key sections from Lathi’s Linear Systems and Signals book (2 nd ed) and Oppenheim &
Willsky’s Signals and Systems book (2nd ed) with respect to material in EE 445S:
O&W Lathi Topic
1.6 1.7 System properties
1.3 – 1.4 1.4 Basic continuous-time signals
3.2 ## 2.4-4 Fundamental theorem for continuous-time linear systems **
1.3 – 1.4 3.3 Basic discrete-time signals
3.2 ## 3.8-3 Fundamental theorem for discrete-time linear systems **
9.7.2 2.6 Stability of continuous-time filters
10.7.2 3.10 Stability of discrete-time filters
10.1 – 10.3 5.1 Z transforms
10.5 5.2 Properties of the z-transform
10.7.3 – 10.7.4 5.3 Transfer functions
10.8 5.4 Realizations of transfer functions
4.3 – 4.4 7.3 Fourier transform properties
7.1 8.1 Sampling theorem
** Please see Appendix F and slide 5-13 in the course reader for the fundamental theorem.
## O&W covers a slightly different version of the fundamental theorem in which a complex
exponential is the input to a linear time-invariant system. Lathi also has that version as well.
You may use any computer program to help you solve these problems, check answers, etc. Please
submit any MATLAB code that you have written for the homework solution. In the course reader,
Appendix D gives a brief introduction to MATLAB. The MATLAB code in the Johnson, Sethares
and Klein book also runs in LabVIEW Mathscript and GNU Octave.
3:00 pm Sinno
(ENS 137)
3:30 pm Sinno Jia
(ENS 137) (ENS 137)
4:00 pm Sinno Jia
(ENS 137) (ENS 137)
4:30 pm Jia
(ENS 137)
5:00 pm Jia
(ENS 137)
5:30 pm Sinno
(ENS 137)
6:00 pm Sinno
(ENS 137)
Please read the homework hints that are available on the homework Web page.
2.2. Finite Impulse Response Filter Design for Audio Signals. 30 points.
Johnson, Sethares & Klein, exercise 7.21, on page 149. Complete all parts. Please use a lowpass filter
in part (a). In addition, please complete the following additional part:
(e) Take the filtered gong signal from (b) and perform downsampling by 2. Downsampling by 2
keeps every other sample and discards the rest. Here’s Matlab code for downsampling vector
vec by 2:
vecDownsampledBy2 = vec(1:2:length(vec));
Play the downsampled filtered gong signal at the same playback rate as the filtered gong
signal. How does it differ from the filtered gong signal?
Plot the magnitude spectrum of the downsampled filtered gong signal and compare it
against the magnitude spectrum of the filtered going signal.
Please submit your Matlab code and the plots with your homework solution.
For the sanity of others, you might put in a pair of headphones when working this problem.
The firpm command stands for finite impulse response design using the Parks-McClellan algorithm.
The Parks-McClellan algorithm was proposed by James McClellan in his 1973 PhD dissertation,
which he completed at Rice University under the research supervision of Thomas Parks. James
McClellan lived in Austin 1981-1987. Since 1987, James McClellan has been a faculty member at
Georgia Tech. Thomas Parks retired from the faculty at Cornell University several years ago.
Downsampling is the removal of samples in a regular fashion. The problem uses downsampling by 2.
The first sample and every other sample thereafter is kept, and hence, the second sample and every
other sample thereafter is removed. Downsampling by would halve the number of samples.
Upsampling is the addition of samples in a regular fashion. After every sample in a signal,
upsampling by 2 would add a sample of value zero. Upsampling by 2 would double the number of
samples. After Spring Break, we'll make heavy use of upsampling in a communications transmitter
and downsampling in a communications receiver.
Please read the homework hints that are available on the homework Web page.
2.3. Finite Impulse Response (FIR) Filter Design for an ECG Device. 46 points.
This problem asks you to design a discrete-time filter for an electrocardiogram signal.
"An electrocardiogram (ECG) device monitors the cardiac status of a patient by recording the heart’s
electrical potential versus time. Such devices play a very important role to save life of patients who
survive heart attack or suffer from serious heart diseases. The time to respond to a heart attack is very
critical for these patients. An early detection of conditions that lead to the onset of cardiac arrest
allows doctors to provide proper treatment on time and prevents death or disability from cardiac
arrest." [1]
"There exist three types of noise that contaminate the ECG signal: the baseline wander noise (BW),
electromyographic interference (EMG), and the power line interference. The BW is induced by
electrodes’ changes due to perspiration, movement and respiration, and is typically below 0.5 Hz. The
power line interference [is] either 50 Hz or 60 Hz and its harmonics are a significant source of noise."
[1] EMG noise appears in the same frequencies as the ECG signal.
Our goal in designing the filter is to attenuate (reduce) the baseline wander noise and powerline
interference. It would take sophisticated processing to track and cancel the EMG noise.
These specifications would be compatible with the monitor mode in modern ECG monitors.
Please use a sampling rate of 200 Hz. From a quick “sampling” of commercial ECG systems, I
found sampling rates that vary from 100 Hz to 1000 Hz. The PTB Diagnostic ECG Database uses a
sampling rate of 1000 Hz and the QT ECG Database uses a sampling rate of 250 Hz.
(a) Design FIR filters with the minimum filter order to meet the specification by using the Parks-
McClellan (Remez), FIR Least Squares (FIRLS), and Kaiser Window design methods. Turn in a
plot of the magnitude and phase response for each filter. Please see the hints below. 27 points.
(b) Plot the impulse response of the FIR filter designed by the Parks-McClellan (Remez) algorithm.
What symmetry is in the impulse response? 7 points.
(c) Give the filter lengths required for filters designed for each filter design method. Which method
gives the shortest filter length? 6 points.
(d) Analyze the implementation complexity of each FIR filter design:
1) How many multiplication operations are needed? 3 points
2) How much memory (in words) would it take to store the FIR coefficients and the circular
buffer for the current and past inputs? 3 points
For lowpass filter design, a common rule-of-thumb is that the distance from the passband frequency to
the stopband frequency should be at least 10% of passband bandwidth. The same rule-of-thumb can
be applied to bandpass filter design. In the above bandpass filter design specification, each transition
band is 5 Hz which is slightly more than 10% of the passband bandwidth of 34 Hz.
Feel free to use Matlab, LabVIEW, or any other computer software on this problem. In Matlab, I’d
recommend using the filter design and analysis tool, fdatool. This tool is particularly useful when
exploring different filter structures for implementation. If you type help fdatool in Matlab, then you
will see how to retrieve the transfer function for the current filter being designed. LabVIEW has
several filter design demonstrations in the filter design toolkit, e.g. Advanced Remez FIR Design.
Hints for Part (a)
For FIR filters, the filter length is the filter order plus one. That is, the filter order is the number of
zeros, and the filter length is the number of coefficients. In all three FIR filter design algorithms, you
will likely have to search for the design with minimum filter order.
By looking at the plots of the magnitude responses, validate that the filters designed meet the
specifications. In particular, carefully inspect the magnitude response in the stopband. In making sure
that each filter design meets specifications, be sure to check the graphical views of the passband and
stopband, i.e. zoom in on the magnitude response near the passband frequency and near the stopband
frequency. For example, the FIR Least Squares method commonly misses the stopband specification.
If you are not absolutely sure from visually inspecting the magnitude response, then you can compute
the magnitude response is at a particular frequency using the freqz function in Matlab. The
arguments are the filter transfer function (type help fdatool to find out how to obtain the transfer
function of the current design) and the frequency in Hz. Then, you can take the magnitude of the
result. Finally, you'll need to convert the magnitude to dB using
20 log10 magnitude
When the filter design does not meet specification, one can adjust the filter parameters entered in
design tool gradually until the filter design meets specification. In particular, one can increase the
stopband attenuation value for Parks-McClellan and Kaiser window design methods and decrease the
stopband frequency for the FIR Least Squares method.
Please read additional homework hints that are available on the homework Web page.
References
[1] Yong Lian and Jianghong Yu, "A Low Power Linear Phase Digital FIR Filter for Wearable ECG
Device", Proc. IEEE International Conference on Engineering in Medicine and Biology Society, pp.
7357-7360, 2005.