LAB 8 - Sampling and Reconstruction of Signals
LAB 8 - Sampling and Reconstruction of Signals
LAB 8
• All tasks must be completed in this lab session for full credit.
• Students must show the output and MATLAB code for each task to the instructor
before proceeding to the next task.
References:
1.1 SAMPLING
Let 𝑥(𝑡) be an analog (absolutely integrable) signal. Its continuous-time Fourier transform (CTFT) is given by
∞
𝑋𝐶 (𝑗Ω) ≡ 𝑋𝐶 (Ω) = ∫ 𝑥(𝑡)𝑒 −𝑗Ω𝑡 𝑑𝑡, (1)
−∞
where Ω is an analog frequency in rad/sec. The inverse continuous-time Fourier transform is given by
1 ∞
𝑥(𝑡) = ∫ 𝑋 (Ω)𝑒 𝑗Ω𝑡 𝑑Ω . (2)
2𝜋 −∞ 𝐶
We now sample 𝑥(𝑡) at sampling interval 𝑇 seconds apart to obtain the discrete-time signal 𝑥[𝑛] as
𝑥[𝑛] = 𝑥(𝑛𝑇).
Let 𝑋(𝑒 𝑗𝜔 ) ≡ 𝑋(𝜔) be the discrete-time Fourier transform of 𝑥[𝑛]. Then it can be shown [2, 3] that 𝑋(𝜔) is a
countable sum of amplitude-scaled, frequency-scaled, and translated versions of the Fourier transform 𝑋𝐶 (Ω),
i.e.,
∞
1 𝜔 2𝜋𝑘
𝑋(𝜔) = ∑ 𝑋𝐶 ( − ). (3)
𝑇 𝑇 𝑇
𝑘=−∞
This relation is known as the aliasing formula. The analog and digital frequencies are related through the
following relation
𝜔 = Ω𝑇, (4)
1
𝐹𝑆 = . (5)
𝑇
From (3), we observe that, in general, the discrete signal is an aliased version of the corresponding analog
signal because higher frequencies are aliased into lower frequencies if there is an overlap between the
𝜔 2𝜋𝑘
consecutive 𝑋𝐶 ( 𝑇 − 𝑇 ). However, it is possible to recover the Fourier transform 𝑋𝐶 (Ω) from 𝑋(𝜔) (or
equivalently, the analog 𝑥(𝑡) from its samples 𝑥[𝑛]) if the infinite replicas of 𝑋𝐶 (Ω) do not overlap with each
other to form 𝑋(𝜔), which is true only for bandlimited analog signals, i.e., those analog signal 𝑥(𝑡) for which
Otherwise, aliasing would occur in 𝑥[𝑛]. The sampling rate of 2𝐹0 for an analog band-limited signal is called
the Nyquist rate.
Note that after 𝑥(𝑡) is sampled, the highest analog frequency that 𝑥[𝑛] represents is 𝐹𝑆 /2 (or 𝜔 = 𝜋).
2
smooth plot and a large enough maximum time to show all the modes, then we can approximate its analysis. Let
∆𝑡 be the grid interval such that ∆𝑡 ≪ 𝑇. Then, the grid sequence
can be used as an array to simulate an analog signal. The sampling interval 𝑇 should not be confused with the
grid interval ∆𝑡, which is used strictly to represent an analog signal in MATLAB. Similarly, the Fourier
transform relation in (1) should also be approximated in light of (8) as follows:
Now if 𝑥(𝑡), and hence 𝑥𝐺 (𝑚), is of finite duration, then (9) is similar to the discrete-time Fourier transform,
given below in (10), and hence can be implemented in MATLAB in a similar fashion to analyze the sampling
phenomenon.
∞
𝜋
𝑋(𝜔𝑘 ) = ∑ 𝑥[𝑛]𝑒 −𝑗𝜔𝑘𝑛 , 𝜔𝑘 = 𝑘, 𝑘 = 0,1, … , 𝑀. (10)
𝑀
𝑛=−∞
Example 1
Let 𝑥(𝑡) = 𝑒 −1000|𝑡| . Then, using (1), we find the continuous-time Fourier transform as
0 ∞
0.002
𝑋𝐶 (Ω) = ∫ 𝑒 1000𝑡 𝑒 −𝑗Ω𝑡 𝑑𝑡 + ∫ 𝑒 −1000𝑡 𝑒 −𝑗Ω𝑡 𝑑𝑡 = .
−∞ 0 Ω 2
1 + (1000)
In order to evaluate 𝑋𝐶 (Ω) numerically, we have to approximate 𝑥(𝑡) with the grid sequence 𝑥𝐺 (𝑚), for which,
value of ∆𝑡 ≪ 𝑇 is required. From the above expression of 𝑋𝐶 (Ω), we see that
𝑋𝐶 (Ω) ≈ 0 if Ω ≥ Ω0 = 2𝜋(2000).
Hence, we choose Ω0 = 2𝜋(2000) rad/sec or 𝐹0 = 2000 Hz as the bandwidth of the signal 𝑥(𝑡). Choosing the
sampling frequency 𝐹𝑆 = 2𝐹0 (the Nyquist rate), we can find the grid interval as
1 1
∆𝑡 ≪ 𝑇 = = = 25 × 10−5 ,
𝐹𝑆 2(1000)
from which we can choose ∆𝑡 = 5 × 10−5 secs. Then, 𝑥𝐺 (𝑚) = 𝑥(𝑚 5 × 10−5 ). Also, since 𝑒 −5 =
𝑒 −1000|±0.005| ≈ 0, we approximate 𝑥(𝑡) with a finite-duration signal over the time interval −0.005 ≤ 𝑡 ≤
0.005. Hence, the grid sequence, which is a MATLAB implementation of 𝑥(𝑡), is given by
−5 |
𝑥𝐺 (𝑚) = 𝑒 −1000|𝑚 5×10 for −100 ≤ 𝑚 ≤ 100.
Now, to study the effects of sampling, we sample 𝑥(𝑡) at 𝐹𝑆 = 5000 samples/sec, which gives a sampling
period of 𝑇 = 0.2 msecs, to obtain 𝑥[𝑛] = 𝑥(𝑛𝑇). We note that −25 ≤ 𝑛 ≤ 25 for −0.005 ≤ 𝑛𝑇 ≤ 0.005.
Following is the MATLAB script for this implementation.
3
>> % Constructing the analog signal
>> Dt = 5e-5; m = -100:100; xG = exp(-1000*abs(m*Dt));
4
Task 1
Simulate the above piece of code in MATLAB. Why does the DTFT look similar to the CTFT ?
Task 2
Sample the signal in Example 1 at 𝐹𝑆 = 1000 samples/sec. Does the DTFT in this case look different from the
CTFT ? If yes, then why ?
• Then, the impulse train is filtered through an ideal low-pass filter whose spectrum and impulse response
is given by [2, 3]
𝜋 𝜋
Ω 𝑇, Ω ∈ [− , ] , sin 𝜋𝑡/𝑇
𝐻𝑟 (Ω) = 𝑇 rect ( )={ 𝑇 𝑇 ℎ𝑟 (𝑡) = . (12)
2𝜋/𝑇 0, otherwise. 𝜋𝑡/𝑇
5
The reconstructed signal is then given by
∞
sin 𝜋(𝑡 − 𝑛𝑇)/𝑇
𝑥𝑟 (𝑡) = ∑ 𝑥[𝑛] . (13)
𝜋(𝑡 − 𝑛𝑇)/𝑇
𝑛=−∞
The expression in (13) is the ideal interpolation formula from signal reconstruction from its samples generated
with a period of 𝑇.
sin 𝜋(𝑚∆𝑡)/𝑇
ℎ𝑟 (𝑚∆𝑡) = , (14)
𝜋(𝑚∆𝑡)/𝑇
which gives the reconstructed signal, from the discrete-time sequence 𝑥[𝑛], 𝑛1 ≤ 𝑛 ≤ 𝑛2 , as
𝑛2
sin 𝜋(𝑚∆𝑡 − 𝑛𝑇)/𝑇
𝑥𝑟 (𝑚∆𝑡) ≈ ∑ 𝑥[𝑛] , 𝑡1 ≤ 𝑚∆𝑡 ≤ 𝑡2 . (15)
𝜋(𝑚∆𝑡 − 𝑛𝑇)/𝑇
𝑛=𝑛1
The expression in (15) can be evaluated in MATLAB using the following piece of code:
Note that the command ones(length(n), 1)*m*Dt makes n vertical copies of the row vector m*Dt and the
command (n.')*T*ones(1, length(m)) makes m horizontal copies of the column vector (n.')*T.
Task 3
1. 𝐹𝑆 = 3000 samples/sec,
2. 𝐹𝑆 = 6000 samples/sec,
and reconstruct the analog signal using ideal interpolation formula in (13). Plot the original and reconstructed
analog signals on the same graph for both cases and comment on the similarity/dissimilarity between them.
6
Exercises:
Use the values of 𝒎, 𝒏, ∆𝒕 and 𝑭𝟎 from Example 1 for 𝒙(𝒕) = 𝒆−𝟏𝟎𝟎𝟎|𝒕| in the following
problems.
1. A zero-order-hold interpolation holds the value of the sample until next sample is received, i.e.,
which can be obtained by convolving the impulse train in (11) with a filter having the following impulse
response
1, 0 ≤ 𝑡 ≤ 𝑇,
ℎ0 (𝑡) = {
0, otherwise.
Sample 𝑥(𝑡) at 𝐹𝑆 = 6000 samples/sec and plot the original and zero-order-held reconstructed signal on
the same graph.
2. A first-order-hold interpolation joins the consecutive samples of the discrete-time signal with a straight
line to give the reconstructed analog signal. Such reconstructed signal can be obtained by convolving the
impulse train in (11) with a filter having the following impulse response
|𝑡|
ℎ1 (𝑡) = {1 − , − 𝑇 ≤ 𝑡 ≤ 𝑇,
𝑇
0, otherwise.
Sample 𝑥(𝑡) at 𝐹𝑆 = 8000 samples/sec and plot the original and first-order-held reconstructed signal on
the same graph.