0% found this document useful (0 votes)
165 views9 pages

ECE3161 Sampling Theorem Lab Report

The document outlines a lab report for ECE3161 focusing on the verification of the sampling theorem in digital signal processing. It includes objectives, theoretical background, MATLAB code examples for sampling demonstrations, and exercises to analyze aliasing effects based on different sampling frequencies. The report emphasizes the importance of adhering to the Nyquist sampling rate to avoid aliasing and ensure accurate signal reconstruction.

Uploaded by

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

ECE3161 Sampling Theorem Lab Report

The document outlines a lab report for ECE3161 focusing on the verification of the sampling theorem in digital signal processing. It includes objectives, theoretical background, MATLAB code examples for sampling demonstrations, and exercises to analyze aliasing effects based on different sampling frequencies. The report emphasizes the importance of adhering to the Nyquist sampling rate to avoid aliasing and ensure accurate signal reconstruction.

Uploaded by

sekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DEPARTMENT OF ECE

ECE3161-Digital Signal Processing Lab

2. Verification of sampling theorem.

Name: Branch: Lab Section:


Id No:
Level-1 (2M) Level-2 (3M) Post Lab session work (3M) Viva Total Marks
(2M) 10M

Remarks:

Date: Signature of the Instructor Marks awarded

Sampling Theorem
Lab Report
Objective: The objective of this Lab is to understand concepts and observe the effects of periodically sampling a
continuous signal at different sampling rates, changing the sampling rate of a sampled signal, aliasing, and anti-
aliasing filters.

Introduction: The signals we use in the real world, such as our voices, are called "analog" signals. To process these
signals in digital computers or digital systems, we need to convert the signals to "digital" form. While an analog signal
is continuous in both time and amplitude, a digital signal is discrete in both time and amplitude. To convert a signal
from continuous time to discrete time, a process called sampling is used. The value of the signal is measured at certain
intervals in time. Each measurement is referred to as a sample. The analog signal is also quantized in amplitude, but
that process is ignored in this demonstration.

Sampling Theorem: The sampling theorem can be defined in two ways as below.

Time domain Statement: A band limited signal having no frequency components higher than f m Hz may be

completely recovered from the knowledge of its samples taken at the rate of at least 2 f m samples per second.

Frequency domain Statement: A band limited signal having no frequency components higher than f m Hz is

completely described by its sample values at uniform intervals less than or equal to 1 / 2 f m seconds apart.
Basic theory: A simple process of sampling and reconstruction is illustrated in Fig1.
DEPARTMENT OF ECE
ECE3161-Digital Signal Processing Lab

The uniform sampling and reconstruction process is illustrated in Fig.1. Let us consider a band limited signal x(t )

having no frequency components beyond f m Hz, i.e., X (ω) is zero for | ω | ωm , where ωm 2 f m . When this

signal is multiplied by a periodic impulse function  T (t ) (with period ‘ T ’), the product yields a sequence of impulses

located at uniform intervals of T seconds. The strength of resulting impulses is equal to the value of x(t ) at the
corresponding instants.

 (ω)
The Fourier transforms of the band limited signal x(t ) and the impulse train  T (t ) are X (ω) and ωs shown

in Fig 2(a) and (b) respectively. The product of x(t ) and  T (t ) yields a discrete time signal xs (t ) as shown in Fig

2(c). The corresponding spectrum X s (ω) can be determined by frequency convolution theorem as below.
 ωs (ω)
We know that the Fourier Transform of periodic impulse train is also periodic function and can be written

as the sum of impulses located at ω 0, ωs , ωs ,...

Then the sampled signal is given by


DEPARTMENT OF ECE
ECE3161-Digital Signal Processing Lab

 (ω)
Thus the spectrum X s (ω) is obtained by convolving X (ω) and ωs represents X (ω) repeating every ωs

rad/sec. It is obvious from X s (ω) shown in Fig 2(c), that X (ω) will repeat periodically without overlapping
2 1
 2(2 f m ) fs 
ω
provided s 2 ωm or T . That is the sampling rate T is given as f s 2 f m .
x(t )
Hence the sampling rate should at least be equal to the twice of max frequency component present in the signal .
xs (t )
This means that at least two samples per second are needed for a complete recovery of the signal from . Therefore
f s 2 f m
the minimum sampling rate . This minimum rate of sampling is known as Nyquist sampling rate.

Signal Recovery from its samples: It can be shown that the original signal x(t ) can be recovered by passing its
fc  fm ωc ω m
sampled version through a LPF with a cut off frequency or ).
ω ω 2ω m
Let the function x(t ) is sampled at Nyquist rate s , then we have s .
1  1 
X s (ω)  
T m  
X ( ω - mω s )   X (ω - 2mωm )
T m  
Therefore .
 T ,| ω |< ωc
H (ω) 
The LPF transfer function is given by 0, | ω |> ωc
X r (ω)  X s (ω) H (ω)
Then or

x r (t )  x s (t )  I.F.T  H (ω)
ωs
 x s (t )  T Sa{ω mt}  x s (t )  Sa{ω mt}
2
  
  x n (t  nT )  Sa{ω mt}   Sa{ω m (t  nT )}   Sa (ω mt  n )
n   n   n  
DEPARTMENT OF ECE
ECE3161-Digital Signal Processing Lab

x (t ) x
This equation represents the function r (or equivalent to x(t ) ) can be constructed by multiplying its samples n
Sa (ωmt  n )
with a sampling function and adding the multiplied values. This procedure is referred to as ideal band
x r (t )
limited interpolation using the sync function. The construction of (or equivalent to x(t ) ) is shown in Fig [Link]
Fig 3.

The effect of Under Sampling:


DEPARTMENT OF ECE
ECE3161-Digital Signal Processing Lab

Aliasing: As explained in the previous section, with ωs 2ωm (or f s 2 f m ), the spectrum of sampled signal
consists of scaled replications of the spectrum of x(t ) and thus forms the basis for the sampling theorem. When
ωs  2ωm , X (ω) the spectrum of x(t ) is no longer replicated in X s (ω) and thus no longer recoverable by low
pass filtering. This effect in which the individual terms overlap is referred to as aliasing. It is also called frequency
folding effect. This is illustrated in the figure. The effect of under sampling, whereby higher frequencies are reflected
into lower frequencies. Hence to avoid aliasing, it should be ensured that (i) x(t ) is strictly band limited and (ii) ωs

must be greater than 2ωm .


LEVEL-1

(a) Study and understand the basic theory required for this lab.
(b) Run the Matlab scripts given for examples and study the results.
(c) Perform the analytical solutions for the given laboratory exercises.
(d) Prepare the Matlab codes for the given laboratory exercises well before the commencement of lab
scheduled time. Discuss with your lab instructors.

EXAMPLE 1: Time domain sampling demonstration


MATLAB CODE:
clear all; close all; clc;
f0=1000; %Freqyency of sin
fs1=10000; %Sampling Frequency Fs>2Fm
fs2=1500; %Sampling Frequency Fs<2Fm

n=[Link];
x=cos(2*pi*f0*n/fs1);
x1=cos(2*pi*f0*n/fs2);

figure ()
plot(n,x, 'm','LineWidth',2); title('Original Signal');

figure();
plot(n,x, 'b','LineWidth',2);hold on
stem(n,x,'--r','fill','LineWidth',2);
plot(n,x1,'k','LineWidth',2);
title('Sampling');
DEPARTMENT OF ECE
ECE3161-Digital Signal Processing Lab

legend('Original Signal','Sampling with Fs>2Fm','Sampling With Fs<2Fm');


OUTPUT

EXAMPLE 2: Frequency domain sampling demonstration


MATLAB CODE:
clear all; close all; clc;
clf;
% sinusoids
omega_0 = 1; omega_s = 7;
T = 2* pi/omega_0;
t = 0:0.001:2*T; % a period of x1

x1 = cos(omega_0* t);
x2 = cos((omega_0 + omega_s)*t);

N = length(t);
Ts = 2*pi/omega_s; % sampling period
DEPARTMENT OF ECE
ECE3161-Digital Signal Processing Lab

M = fix(Ts/0.001);
imp = zeros(1,N);

for k = 1:M:N-1.
imp(k) = 1; % sequence of impulses
end
xs = imp.*x1; % sampled signal

plot(t,x1,'b',t,x2,'k'); hold on
stem(t,imp.*x1,'r','filled');
axis([0 max(t) -1.1 1.1]); xlabel('t'); grid
OUTPUT

LEVEL-2
(a) Execute the Matlab codes prepared for the exercises and observe the results.
(b) Compute all the tasks given in the exercises.
(c) Note the results and store the necessary figures and data for the lab report.

EXERCISE 1: Consider a multitone signal

.
Suppose this signal is sampled with the following sampling frequencies.
(a) 600 sam/sec (b) 1200 sam /sec
Is there any aliasing effect? If these sampled signals are reconstructed, what are the frequency components are
available? Develop Matlab codes, sketch and label them. Draw the corresponding spectra.
MATLAB CODE:
DEPARTMENT OF ECE
ECE3161-Digital Signal Processing Lab

% Define the signal parameters


f1 = 100; % Frequency of the first cosine component (Hz)
f2 = 300; % Frequency of the second cosine component (Hz)
f3 = 400; % Frequency of the third cosine component (Hz)
t = 0:0.0001:0.02; % Time vector for continuous signal

% Generate the continuous-time signal


x_t = cos(2*pi*f1*t) + cos(2*pi*f2*t) + cos(2*pi*f3*t);

% Sampling frequencies
fs_a = 600; % Sampling frequency for case (a)
fs_b = 1200; % Sampling frequency for case (b)

% Sampling time vectors


Ts_a = 1/fs_a;
Ts_b = 1/fs_b;
n_a = 0:Ts_a:0.02; % Sampling instants for case (a)
n_b = 0:Ts_b:0.02; % Sampling instants for case (b)

% Sampled signals
x_a = cos(2*pi*f1*n_a) + cos(2*pi*f2*n_a) + cos(2*pi*f3*n_a);
x_b = cos(2*pi*f1*n_b) + cos(2*pi*f2*n_b) + cos(2*pi*f3*n_b);

% Reconstructed signals (using zero-order hold)


x_a_reconstructed = interp1(n_a, x_a, t, 'previous');
x_b_reconstructed = interp1(n_b, x_b, t, 'previous');

% Frequency analysis
N = 1024; % Number of FFT points
f = (-N/2:N/2-1)*(fs_a/N); % Frequency vector for case (a)
X_a = fftshift(fft(x_a_reconstructed, N));
X_b = fftshift(fft(x_b_reconstructed, N));

% Plot the results


figure;

% Case (a): fs = 600 Hz


subplot(2, 2, 1);
plot(t, x_t, 'b', n_a, x_a, 'ro', t, x_a_reconstructed, 'g');
title('Case (a): fs = 600 Hz');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Original Signal', 'Sampled Signal', 'Reconstructed Signal');

subplot(2, 2, 2);
plot(f, abs(X_a)/N);
title('Spectrum for Case (a)');
xlabel('Frequency (Hz)');
ylabel('Magnitude');

% Case (b): fs = 1200 Hz


subplot(2, 2, 3);
plot(t, x_t, 'b', n_b, x_b, 'ro', t, x_b_reconstructed, 'g');
title('Case (b): fs = 1200 Hz');
DEPARTMENT OF ECE
ECE3161-Digital Signal Processing Lab

xlabel('Time (s)');
ylabel('Amplitude');
legend('Original Signal', 'Sampled Signal', 'Reconstructed Signal');

subplot(2, 2, 4);
plot(f, abs(X_b)/N);
title('Spectrum for Case (b)');
xlabel('Frequency (Hz)');
ylabel('Magnitude');

OUTPUT:

POST LAB SESSION:


(a) Complete the lab work in all aspects in the given specified lab time.
(b) Answer for the given questions.
(c) Submit the lab report to the lab in-structure and get the signature in time.
(d) Type the complete description of commands used in the lab.

You might also like