Lab1 Sampling and Reconstruction of Analog Signals Spring2023
Lab1 Sampling and Reconstruction of Analog Signals Spring2023
EE092IU
DIGITAL SIGNAL PROCESSING LABORATORY
LAB 1
Date: ………………………………..
Page 1 of 6
INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING (EE)
LAB OBJECTIVES
The objective of this lab is to explore the concepts of sampling and reconstruction of analog
signals. Specifically, we will simulate the sampling process of an analog signal using
MATLAB, investigate the effect of sampling in the time and frequency domains, and introduce
the concept of aliasing.
FUNDAMENTAL DISCUSSION
An analog-to-digital converter (ADC) converts an analog signal to a digital form. An
ADC produces a stream of binary numbers from analog signals by taking the samples
of the analog signal and digitizing the amplitude at these discrete times. Prior to the
ADC conversion, an analog filter called the prefilter or antialiasing filter is applied to
the analog signal in order to deal with an effect known as aliasing. Aliasing causes
multiple continuous time signals to yield the exact same sampled discrete time signal.
In this lab we focus our attention in the process of sampling and how to avoid the
problem of aliasing. During sampling, an analog signal 𝑥𝑎 (𝑡 ) is periodically measured
every 𝑇𝑠 seconds:
𝑡 = 𝑛𝑇𝑠 , 𝑛 = 0,1,2 … (1)
where 𝑇𝑠 is called the sampling period, and is the fixed time interval between samples
(here we assume a uniform sampling rate that does not change with time.) The inverse
of Ts is called the sampling frequency, that is, the samples per second:
𝑓𝑠 = 1⁄𝑇 (2)
𝑠
When sampling an analog signal, we must sample fast enough (i.e. be sure 𝑓𝑠 is
sufficiently high), so that the samples are a good representation of the original analog
signal. If the sampling frequency fs is not fast enough then too much information is lost,
and it becomes impossible to reconstruct our original analog signal using a digital-to-
analog converter (DAC). However, if you do sample fast enough, then, theoretically, it
is possible to exactly reconstruct the original signal.
Sampling theorem:
For accurate representation of signal 𝑥𝑎 (𝑡 ) by its time samples 𝑥 [𝑛𝑇], two conditions
must be met:
1) The signal 𝑥𝑎 (𝑡 ) must be bandlimited, that is, its frequency content (spectrum) must
be limited to contain frequencies up to some maximum frequency 𝑓𝑚𝑎𝑥 and no
frequencies beyond that, and
2) the sampling rate 𝑓𝑠 must be chosen to be at least twice the maximum frequency 𝑓𝑚𝑎𝑥 ,
that is
Page 2 of 6
INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING (EE)
𝑓𝑠 ≥ 2𝑓𝑚𝑎𝑥 (3)
According to the sampling theorem, before sampling we must make sure the signal is
bandlimited (this is the function of the analog prefilter) and that the sampling frequency
is at least twice the maximum frequency.
The traditional Nyquist sampling theorem presented above is true for real-valued (i.e.
not complex), lowpass (i.e. baseband) signals. For complex lowpass signals, the
sampling theorem states that the ultimate minimum sampling rate to avoid aliasing is
actually 𝑓𝑠 = 𝛽, where 𝛽 is the double-sided bandwidth. For bandpass signals, things
get even more interesting. You can subsample (i.e. sample below the Nyquist rate) to
achieve frequency translation to lower frequencies and recover the original signal.
Example 1:
Consider the following continuous time signal:
𝑥𝑎 (𝑡 ) = 3𝑠𝑖𝑛(2𝜋 × 0.5𝑡 ) + 2𝑠𝑖𝑛(2𝜋 × 2.5𝑡 ) (4)
The signal contains two frequency components at 𝑓1 = 0.5𝐻𝑧 and 𝑓2 = 2.5𝐻𝑧. We
explore the effect of aliasing by sampling 𝑥𝑎 (𝑡 ) at 𝑓𝑠 = 2.5𝑓𝑚𝑎𝑥 = 6.25𝐻𝑧. This
sampling frequency meets the sampling theorem requirement. In MATLAB we explore
time-domain by making the following plots:
• The original time signal 𝑥𝑎 (𝑡 )
• The sampled signal 𝑥 [𝑛] (discrete time signal) with 𝑓𝑠 = 2.5𝑓𝑚𝑎𝑥 = 6.25𝐻𝑧
• The sampled signal superimposed on top of the reconstructed continuous time-
signal
Result:
Figure 1 shows the original continuous time signal 𝑥𝑎 (𝑡 ) in the first plot. Second plot
shows the sampled discrete time signal 𝑥 [𝑛] with 𝑓𝑠 = 2.5𝑓𝑚𝑎𝑥 = 6.25𝐻𝑧. Third plot
shows the sampled discrete time signal superimposed on top of the reconstructed time-
domain signal.
Page 3 of 6
INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING (EE)
Page 4 of 6
INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING (EE)
Problem 2:
a) Given the signal 𝑥(𝑡) = 𝑐𝑜𝑠(2𝜋𝑡) + 𝑐𝑜𝑠(8𝜋𝑡) + 𝑐𝑜𝑠(12𝜋𝑡), where 𝑡 is in milliseconds.
Show that if this signal is sampled at a rate of 𝑓𝑠 = 5𝑘𝐻𝑧, it will be aliased with the
following signal, in the sense that their sample values will be the same:
Page 5 of 6
INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING (EE)
𝑥𝑎 (𝑡) = 3𝑐𝑜𝑠(2𝜋𝑡)
On the same graph, plot t 𝑥(𝑡) and 𝑥𝑎 (𝑡) versus 𝑡 in the range 0 ≤ 𝑡 ≤ 2 𝑚𝑠𝑒𝑐. To this
plot, add the time samples 𝑥(𝑛𝑇𝑠 ) and verify that 𝑥(𝑡) and 𝑥𝑎 (𝑡) intersect precisely at these
samples.
b) Restart part (a) with 𝑓𝑠 = 10𝑘𝐻𝑧. In this case, determine the signal 𝑥𝑎 (𝑡) with which 𝑥(𝑡)
is aliased.
Problem 3:
Consider the two sinusoids:
𝑥1 (𝑡) = 𝑐𝑜𝑠(Ω0 𝑡) −∞ ≤ 𝑡 ≤∞
𝑥2 (𝑡) = 𝑐𝑜𝑠[(Ω0 + Ω𝑠 )𝑡] −∞ ≤ 𝑡 ≤∞
2𝜋
Show that if we sample these signals using 𝑇𝑠 = Ω , we cannot differentiate the sampled signals.
𝑠
Do this by first proving the equation 𝑥1 (𝑛𝑇𝑠 ) = 𝑥2 (𝑛𝑇𝑠 ) (Remember to include it in your
report). Then, write a script file to input any 2 angular frequencies, and create a 3-by-1 plot
where the first 2 plots are the given signals, and the final plot is the sampled signals overlap
each other.
Problem 4:
Consider a continuous time domain signal:
a. Write a script file to input the 4 component frequencies, then plot out the 𝑥𝑎 (𝑡)
b. Suppose we sample 𝑥𝑎 (𝑡) with a sampling frequency 𝑓𝑠 = 5𝑓𝑚𝑎𝑥 (𝑓𝑚𝑎𝑥 is the maximum
frequency automatically find out by the script). Write a MATLAB program to create a 3-by-1
plot like Example 1 where you plot the original continuous time signal 𝑥𝑎 (𝑡), the sampled
discrete time signal 𝑥[𝑛], and the sampled discrete time signal superimposed over the
reconstructed signal.
Page 6 of 6