Labsheet 2
Labsheet 2
2. Let x(t) be a continuous time signal 2cos(2000πt) + 5cos(500πt) defined for all t. We define the
following sampling rates: fs,1 = 500, fs,2 = 2000, fs,3 = 4000, where all sampling rates have units
of Hertz. Let xi [n] be the discrete time signal obtained by sampling x(t) at sampling rate fs,i for
t ∈ [0, 8) ms (note that 8 ms is not included)
a) What is the CTFT of x(t)?
b) Plot the magnitude of DFTs of each xi [n]. Compare the magnitude plots? Are they different?
Why do the differences arise?
c) We note that it is possible to obtain a continuous time signal xi (t) from each xi [n] by using sinc
interpolation which we had studied in class. As in question 1, use the DFT of each xi [n] as the
frequency sampled CTFT of xi (t), i.e., make appropriate changes to the frequency axis and
magnitude axis. What frequency components do you get in each xi (t)? How are they different
from those in x(t)? Why? (Please note that you are not asked to do the interpolation!)
4. Let x(t) be 2cos(2000πt). We define the following sampling rates: fs,1 = 8000, fs,2 = 16000,
fs,3 = 8888, fs,4 = 17776, where all sampling rates have units of Hertz.
a) Let xi [n] be the discrete time signal obtained by sampling x(t) at sampling rate fs,i for
t ∈ [0, 8) ms.
5
b) Let yj [n] be the discrete time signal obtained by sampling x(t) at sampling rate fs,i for
t ∈ [0, 8] ms.
c) In each case plot the DFT magnitude and use that to think about the CTFT of x(t).
d) How do each one of the sampled CTFTs that you have “computed using DFT” compare with
the actual CTFT?
e) Let z[n] be the discrete time sequence obtained by sampling x(t) at fs,1 for [0, 4) ms. Extend
the length of z[n] using zero padding so that z[n] has the same length as x1 [n]. Compare the
DFT magnitude plot of z[n] with x1 [n]. Is there a difference? If there is, then explain why?
f) If z(t) is the continuous time signal obtained from z[n], what is the relationship between z(t)
and x(t)?
5. Use internet resources to find out what dual tone multi-frequency (DTMF) signalling is. For
example, look at
a) https://en.wikipedia.org/wiki/Dual-tone multi-frequency signaling
b) http://onlinetonegenerator.com/dtmf.html
When a key is pressed (e.g., on your landline phone) the tone generator would produce a signal for
the duration of the key press which is the sum of a high frequency tone and a low frequency tone.
The high and low frequencies corresponding to different keys are shown in the following table:
We will first make a DTMF tone simulator. Write a Matlab function “makeDTMFsignal” that
takes as input
a) The sequence of key’s pressed (e.g., this input can be the array [1,2]),
b) The duration of each key press in seconds (all key presses are assumed to be of the same
duration, and there is no time taken between two consecutive key presses),
and returns the sampled DTMF signal. Please choose an appropriate sampling rate; justify your
choice. Note that the sampling rate could be another input into your function or hard-coded in
your function. Play the sampled DTMF signal through your computer speakers.
In the second part of this question, you will make a DTMF signal decoder. Note that the DTMF
signal can be decoded by looking at its frequency content, which can be computed via the DFT.
Write a Matlab function “decodeDTMFsignal” that takes as input
a) the sampled DTMF signal that you have produced using “makeDTMFsignal”
b) the duration of each keypress (note that the duration should be the same as that used for
making the sampled DTMF signal you are using as input)
c) the sampling rate used to make the sampled DTMF signal
and returns the sequence of keys that corresponds to the DTMF signal that you have used as input.
Design the function “decodeDTMFsignal” using a flowchart. Note that the decoder needs to decide
during a key press duration whether two frequencies are present in a signal. Since all key presses
have the same duration, an approach would be to
a) segment the sampled DTMF signal into smaller duration signals, each duration being that of
a keypress duration
b) apply DFT to find out the frequency content
c) decide if there is a tone at a particular frequency (how will you make this decision?)
6
2.2 Review of filter design
1. Given the following requirements on a filter in continuous time, manually derive the desired ideal
frequency response Hd (ejω ) in the discrete frequency domain.
❼ sampling frequency = 8kHz, and,
❼ pass all signals below 1kHz with a gain of 1, and,
❼ cutoff all signals above 1kHz (or the cutoff frequency is Ωc = 1kHz).
Also derive the corresponding impulse response hd [n].
❼ In general, what is the ideal lowpass filter response Hd (ejω ) that would also have linear phase
for a cutoff frequency of ωc ?
❼ What is the corresponding impulse response hd [n]?
2. Suppose one desires to design the following low pass filter (this is a specification of the desired
response Hd (ejω )).
(
jω ∈ [1 − 0.01, 1 + 0.01], for 0 ≤ |ω| ≤ 0.25π,
|Hd (e )| is
∈ [0, δ], for |ω| ≥ 0.3π.
a) Obtain a complete specification of Hd (ejω ) so that we have a filter with linear phase response
b) Design filters which meets the above specifications using the frequency sampling method for
the cases δ = 0.01 and δ = 0.001.
c) Plot the desired magnitude plot along with the magnitude plot of the filter that you have
designed and comment on the differences.
d) For each δ above, plot separate magnitude plots of the filters that you have obtain if you apply
circular shifts of M/4 and M/2 to the h[n]. What do you observe?
7
e) Suppose we need to design a filter with δ = 0.001. Using two frequency samples in a “transition
band” is it possible to obtain a δ = 0.001? What should be the values of those two frequency
samples? Is there a tradeoff between δ and M ?
5. Study what the Matlab inbuilt functions “fir2” and “firls” do. Go through the design examples
which are shown in Matlab’s help for these two functions.
6. Study what the Matlab inbuilt function “firpm” (or “remez”) does. Use firpm to design a linear
phase equiripple filter meeting the requirements in Task 1.
7. Matlab also provides filter design tools such as “filterbuilder” and “fdatool”. Explore how these
tools can be used to design FIR filters.