Professional Documents
Culture Documents
EXPERIMENT 02
OBJECTIVE
EQUIPMENTS
THEORY
Signals are physical quantities that carry information in their patterns of variation.
Continuous time signals are continuous functions of time, while discrete-time signals are
sequences of numbers. If the values of a sequence are chosen from a finite set of numbers, the
sequence is known as a digital signal. Continuous-time, continuous-amplitude signals are also
known as analog signals.
Sampling
Sampling Theorem
A continuous time signal x(t) can be reconstructed exactly from its samples x(n)=x(nTs), if
the samples are taken at a rate Fs=1/Ts that is greater than 2*Fmax.
Nyquist rate
When sampling frequency is equal to the twice the input signal frequency, the sampling rate
is called Nyquist rate.
Aliasing
A common problem that arises when sampling a continuous signal is aliasing, where a
sampled signal has replications of its sinusoidal components which can interfere with other
components. Itis an effect that causes two discrete time signals to become indistinct due to
improper sampling (fd>1/2). Aliasing also occurs on television whenever we see a car whose
tires appear to be spinning in the wrong direction. A television broadcast can be thought of as
a series of images, sampled at a regular rate, appearing on screen. If the wheels happen to
rotate less than a full circle between frames (images), then they appear to be turning slowly in
the opposite direction.
LAB TASK’s
Q1: Perform sampling on a given signal using MATLAB.
(a)
x(t) = A*sin(2*pi*F*t)
Here,
Amplitude (A) = 1m
Frequency(F)=2 Hz.
Code:
%Plotting the Original Signal:
t=(0:0.001:1);
A=1;%amplitude
F=2;%frequency
x=A*sin(2*pi*F*t);%signal
subplot(2,1,1)
plot(t,x)
title('Original Continous signal')
%Performing the Sampling on Signal
FS=10*F;%sampling frequency
TS=1/FS;%sampling time
N=FS;
N_1=0:TS:N*TS;
X=A*sin(2*pi*F*N_1);%sampled signal
subplot(2,1,2);
stem(N_1,X)
title('Sampled signal')
Output:
Original Continous signal
1
0.5
-0.5
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Sampled signal
1
0.5
-0.5
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Interpretation:
This code produces a continuous sine wave sound with a 2 Hz frequency, which is then
sampled to provide a discrete representation. The smooth sine wave, which symbolizes
the initial continuous signal, is shown in the top subplot. The sampled signal, where
the signal's values are determined at certain time points, is displayed in the bottom
subplot. Sampling is crucial in the signal processing process because it allows
continuous signals to be transformed into digital data that can be processed by
computers or other digital devices. It is a key idea in a variety of industries, including
audio processing, communications, and more.
(b)
x(t) = sin(2*pi* F1*t)+ sin(2*pi* F2*t)
Here,
Frequency(F1)=10 Hz.
Frequency(F2)=20 Hz.
Output:
Original Continous signal
2
-1
-2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Sampled signal
2
-1
-2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Interpretation:
This code demonstrates how a continuous signal with two distinct frequency components,10
Hz and 20 Hz, can be sampled in order to create a discrete representation. The bottom subplot
illustrates the discrete sampling of this signal at regular intervals, highlighting the
significance of sampling in signal processing and digital representation. The top subplot
displays the complex continuous signal created by adding two sinusoidal waves.
Q2: By following the Nyquist criteria reconstruct the signal that you have generated in Q1
(a).
Code:
Output:
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Sampled signal
1
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Reconstructed signal
1
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Interpretation:
The code illustrates the steps involved in sampling a continuous signal, reconstructing it
from the discrete samples, and illustrating the effect of sampling on the signal.
Q3: Can you reconstruct the signal that you have generated in Q1 (a) if don’t follow Nyquist
criteria?
Note: Justify your statement.
Code:
%Plotting the Original Signal:
t=(0:0.001:1);
A=1;%amplitude
F=2;%frequency
x=A*sin(2*pi*F*t);%signal
subplot(3,1,1)
plot(t,x)
title('Original Continous signal')
%Performing the Sampling on Signal
FS=3*F;%sampling frequency
TS=1/FS;%sampling time
N=FS;
N_1=0:TS:N*TS;
X=A*sin(2*pi*F*N_1);%sampled signal
subplot(3,1,2);
stem(N_1,X)
title('Sampled signal')
%Reconstructing the Original signal
T1 = linspace(0, max(N_1), max(N_1)/0.01);%time vector
XS = interp1(N_1, X, T1, 'spline');%recontructed signal
subplot(3,1,3)
plot(T1,XS)
title('Reconstructed signal')
Output:
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Sampled signal
1
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Reconstructed signal
1
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Fig no. 04: Reconstructed signal if it’s don’t follow Nyquist criteria
Statement:
The Nyquist theorem states that in order to accomplish correct reconstruction, the
sampling frequency must be at least twice that of the original signal. The code offered
does not follow this rule. The sampling frequency in this code is set to 10 times the
original frequency rather than being set at twice the original frequency. As a result,
there are aliasing problems, making it impossible to accurately recreate the original
signal.
Q4: Why interpolation is used in reconstruction of sampled signal?
CONCLUSION:
In this lab, we explored how to sample a continuous-time signal using MATLAB. Sampling,
a fundamental idea in signal processing, is essential for transforming continuous signals into
discrete representations appropriate for digital processing.