0% found this document useful (0 votes)
57 views7 pages

LAB 8 - Sampling and Reconstruction of Signals

Uploaded by

Jahanzaib Rana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views7 pages

LAB 8 - Sampling and Reconstruction of Signals

Uploaded by

Jahanzaib Rana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Regd. No.

: _____________________ Name: _____________________ Section: _____________________

LAB 8

Sampling and Reconstruction of Signals


Instructions:

• 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. Digital Signal Processing using MATLAB: A problem solving companion, Vinay K.


Ingle and John G. Proakis, 4th Edition, Cengage Learning, 2016
2. Discrete Time Signal Processing, Alan. V. Oppenheim and Ronald. W. Schafer, 3rd
Edition, Prentice Hall, 2010
3. Digital Signal Processing: Principles, Algorithms, and Applications, John G.
Proakis and Dimitris G. Manolakis, 4th Edition, Prentice Hall, 2007

1. SAMPLING AND RECONSTRUCTION OF ANALOG SIGNALS


In many applications, for example, in digital communications, real-world analog signals are converted into
digital signals using sampling and quantization operations (collectively called analog-to-digital conversion, or
ADC). These discrete-time signals are processed by digital signal processors, and the processed signals are
converted into analog signals using a reconstruction operation (called digital-to-analog conversion, or DAC).
Using Fourier analysis, we can describe the sampling operation from the frequency-domain viewpoint, analyze
its effects, and then address the reconstruction operation. We will also assume that the number of quantization
levels is sufficiently large that the effect of quantization on discrete signals is negligible.

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)

while the sampling frequency 𝐹𝑆 , measured in samples/sec, is given by

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

𝑋𝐶 (Ω) = 0, |Ω| > Ω0 . (6)

1.1.1 SAMPLING THEOREM


A band-limited signal 𝑥(𝑡) with bandwidth 𝐹0 (in Hz) can be reconstructed from its sample values 𝑥[𝑛] =
𝑥(𝑛𝑇) if the sampling frequency 𝐹𝑆 = 1/𝑇 is greater than twice the bandwidth 𝐹0 of 𝑥(𝑡), i.e.

𝐹𝑆 > 2𝐹0 . (7)

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 𝜔 = 𝜋).

1.1.2 MATLAB IMPLEMENTATION


In a strict sense, it is not possible to analyze analog signals using MATLAB unless we use the Symbolic
toolbox. However, if we sample 𝑥(𝑡) on a fine grid that has a sufficiently small time-increment to yield a

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

𝑥𝐺 (𝑚) = 𝑥(𝑚∆𝑡) (8)

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:

𝑋𝐶 (Ω) ≈ ∑ 𝑥𝐺 (𝑚)𝑒 −𝑗Ω𝑚∆𝑡 ∆𝑡 = ∆𝑡 ∑ 𝑥𝐺 (𝑚)𝑒 −𝑗Ω𝑚∆𝑡 . (9)


𝑚 𝑚

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));

>> % Sampling the analog signal to obtain discrete-time signal


>> T = 0.2e-3; n = -25:25; xn = exp(-1000*abs(n*T));

>> % Continuous-time Fourier Transform


>> F_0 = 2000; Omega_0 = 2*pi*F_0;
% Define 2K+1 = 1001 frequency points in [-Omega_0, Omega_0]
>> K = 500; k = -K:K; Omega = k*Omega_0/K;
>> Xc = xG * exp(-1i*Dt*(m.')*Omega) * Dt; Xc = real(Xc);

>> % Discrete-time Fourier Transform


>> K = 500; k = -K:K; w = k*pi/K; % Defining 2K+1 = 1001 frequency points in [-pi, pi]
>> X = xn * exp(-1i*(n.')*w); X = real(X);

% Plotting signals and spectra


>> subplot(3,1,1); plot(m*Dt*1000, xG); xlabel('t (msec)'); ylabel('Amplitude'); hold on
>> stem(n*T*1000, xn);
>> legend('Analog signal', 'Discrete-time signal'); title('Analog and Discrete-Time Signals');
>> subplot(3,1,2); plot(Omega/(2*pi*1000), Xc);xlabel('Frequency (KHz)'); ylabel('Amplitude');
>> title('Continuous-Time Fourier Transform');
>> subplot(3,1,3); plot(w/pi, X); xlabel('Frequency (in pi units)'); ylabel('Amplitude');
>> title('Discrete-Time Fourier Transform');

Figure 1: Implementation of Example 1 in MATLAB

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 ?

1.2 SIGNAL RECONSTRUCTION


From the sampling theorem, it is clear that if we sample bandlimited analog signal 𝑥(𝑡) above its Nyquist rate,
then it can be reconstructed from its samples 𝑥[𝑛]. This reconstruction can be thought of as a two-step process:

• First, the samples are converted into a weighted impulse train:


𝑥𝑆 (𝑡) = ∑ 𝑥[𝑛]𝛿(𝑡 − 𝑛𝑇) . (11)


𝑛=−∞

• 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 𝑇.

1.2.1 MATLAB IMPLEMENTATION


The ideal reconstruction or low-pass or interpolation filter in (12) is implemented in MATLAB as

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:

>> n = n1:n2; t = t1:t2; m = (1/Dt)*t;


>> xr = xn * sinc( (1/T) * ( ones(length(n), 1)*m*Dt - (n.')*T*ones(1, length(m)) ) );

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

Using the values of 𝑚, 𝑛, ∆𝑡 and 𝐹0 from Example 1, sample 𝑥(𝑡) = 𝑒 −1000|𝑡| at

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.,

𝑥𝑟 (𝑡) = 𝑥[𝑛], 𝑛𝑇 ≤ 𝑡 ≤ (𝑛 + 1)𝑇,

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.

You might also like