Experiments1 5
Experiments1 5
Experiments1 5
Theory:-
Sampling is the process of recording the values of a signal at given points in time. For
A/D converters, these points in time are equidistant. The number of samples taken
during one second is called the sample rate. Keep in mind that these samples are still
analogue values. The mathematic description of the ideal sampling is the multiplication
of the signal with a sequence of direct pulses. In real A/D converters the sampling is
carried out by a sample-and-hold buffer. The sample-and-hold buffer splits the sample
period in a sample time and a hold time. In case of a voltage being sampled, a capacitor
is switched to the input line during the sample time. During the hold time it is detached
from the line and keeps its voltage.
Sample is a piece of data taken from the whole data which is continuous in the time
domain.
When a source generates an analog signal and if that has to be digitized, having 1s and
0s i.e., High or Low, the signal has to be discretized in time. This discretization of
analog signal is called as Sampling.
Sampling Rate
To discretize the signals, the gap between the samples should be fixed. That gap can
be termed as a sampling period Ts.
Sampling frequency is the reciprocal of the sampling period. This sampling frequency,
can be simply called as Sampling rate. The sampling rate denotes the number of
samples taken per second, or for a finite set of values.
Reconstruction is the process of creating an analog voltage (or current) from samples.
A digital-to-analog converter takes a series of binary numbers and recreates the
voltage (or current) levels that corresponds to that binary number. Then this signal is
filtered by a lowpass filter.
Reconstruction is the process of creating an analog voltage (or current) from samples. A
digital-to-analog converter takes a series of binary numbers and recreates the voltage
(or current) levels that corresponds to that binary number. Then this signal is filtered by
a lowpass filter. This process is analogous to interpolating between points on a graph,
but it can be shown that under certain conditions the original analog signal can be
reconstructed exactly from its samples. Unfortunately, the conditions for exact
reconstruction cannot be achieved in practice, and so in practice the reconstruction is
an approximation to the original analog signal.
Code:-
clear; // Remove clear, clc from code if you want to access existing stored variable from
the memory
//Example 1.1
//Sketch the continuous time signal x(t)=2*exp(-2t) and also its discrete time equivalent
signal with a sampling period T = 0.2sec
clear;
clc ;
close ;
t=0:0.01:2;
x1=2*exp(-2*t);
subplot(1,2,1);
plot(t,x1);
xlabel('t');
ylabel('x(t)');
title('CONTINUOUS TIME PLOT');
n=0:0.2:2;
x2=2*exp(-2*n);
subplot(1,2,2);
plot2d3(n,x2);
xlabel('n');
ylabel('x(n)');
title('DISCRETE TIME PLOT');
Output:-
Experiment No.2
Aim:- To perform Discrete Correlation.
Theory:-
The cross correlation between a pair of sequences x(n) and y(n) is given by
The index n is the shift (lag) parameter. The order of subscripts xy indicates that x(n) is
the reference sequence that remains fixed, i.e. unshifted in time, whereas the sequence
y(n) is shifted n units in time w.r.t. x(n).
If we wish to fix the sequence y(n) and to shift the sequence x(n), then the correlation
can be written as:
Observing the above equation for Rxy(n), we can conclude that the correlation of two
sequences is essentially the convolution of two sequences in which one of the
sequence has been reversed, i.e., correlation is the convolution of one signal with a
flipped version of the other. Therefore, the same algorithm (procedure) can be used to
compute the convolution and correlation of two sequences.
Code:-
clear; // Remove clear, clc from code if you want to access existing stored variable from
the memory
//Example 1.18
//Program to Compute Cross-correlation of given sequences
//x(n)=[1 2 1 1], h(n)=[1 1 2 1];
clear;
clc ;
close ;
x=[1 2 1 1];
h=[1 1 2 1];
h1=[1 2 1 1];
y=convol(x,h1);
disp(round(y));
Output:-
f =
50.
diff1 =
column 1 to 6
column 7 to 12
column 13 to 18
column 19 to 23
Experiment No.3
It is based on the concepts of linearity and time invariance and assumes that the
system information is known in terms of impulse response. Correlation is a measure of
similarity between two signals and is found using a process similar to convolution. There
are two types of correlation: cross correlation and autocorrelation. In this chapter,
various methods of evaluating the discrete convolution of finite duration sequences, and
periodic sequences are discussed.
The discrete cross correlation and autocorrelation and evaluation of these are also
discussed.
Convolution is a mathematical operation used to express the relation between input and
output of an LTI system. It relates input, output and impulse response of an LTI system
as
y(t)=x(t)∗h(t)
● Continuous convolution
● Discrete convolution
Continuous Convolution
Discrete Convolution
Code:-
clear; // Remove clear, clc from code if you want to access existing stored variable from
the memory
//Example 3.16
//Program to Compute circular convolution of following sequences
//x1[n]=[1,1,2,1]
//x2[n]=[1,2,3,4]
clear;
clc ;
close ;
x1=[1,1,2,1];
x2=[1,2,3,4];
//DFT Computation
X1=fft(x1,-1);
X2=fft(x2,-1);
X3=X1.*X2;
//IDFT Computation
x3=fft(X3,1);
//Display sequence x3[n] in command window disp(x3,"x3[n]=");
Output:-
Experiment No.4
Theory:-
The DFT is one of the most powerful tools in digital signal processing which enables us
to find the spectrum of a finite-duration signal. There are many circumstances in which
we need to determine the frequency content of a time-domain signal. For example, we
may have to analyze the spectrum of the output of an LC oscillator to see how much
noise is present in the produced sine wave.
This can be achieved by the discrete Fourier transform (DFT). The DFT is usually
considered as one of the two most powerful tools in digital signal processing (the other
one being digital filtering), and though we arrived at this topic introducing the problem of
spectrum estimation, the DFT has several other applications in DSP.
DFT The N-point DFT of a finite duration sequence x(n) of length L, where N L is
defined as:
IDFT The Inverse Discrete Fourier transform (IDFT) of the sequence X(k) of length N is
defined as:
The Fourier series representation of a periodic discrete-time sequence is called discrete
Fourier series (DFS). Consider a discrete-time signal x(n), that is periodic with period N
defined by x(n) = x(n + kN) for any integer value of k.
The periodic function x(n) can be synthesized as the sum of sine and cosine sequences
(Trigonometric form of Fourier series)or equivalently as a linear combination of complex
exponentials (Exponential form of Fourier series) whose frequencies are multiples of the
fundamental frequency 0 = 2/N.
This is done by constructing a periodic sequence for which each period is identical to
the finite length sequence.
The exponential form of the Fourier series for a periodic discrete-time signal is given
By
Code:-
//Example 3.3
//Program to Compute the 8-point DFT of the Sequence x[n]=[1,1,1,1,1,1,0,0]
clear;
clc ;
close ;
x = [1,1,1,1,1,1,0,0];
//DFT Computation
X = fft (x , -1);
//Display sequence X[k] in command window
disp(X,"X[k]=");
Output:-
Experiment No.5
Aim:- To perform fast fourier transform.
Theory:-
A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier
transform (DFT) of a sequence, or its inverse (IDFT). Fourier analysis converts a signal
from its original domain (often time or space) to a representation in the frequency
domain and vice versa.
FFT algorithm exploits the above two symmetry properties and so is an efficient
algorithm for DFT computation.
where r1 = r2 = r3 = ... = rm, then N = rm, can be decimated into r-point sequences.
For each r-point sequence, r-point DFT can be computed. Hence the DFT is of size r.
The number r is called the radix of the FFT algorithm and the number m indicates the
number of stages in computation. From the results of r-point DFT, the r2
-point DFTs are computed. From the results of r2
-point DFTs are computed and so on, until we get rm-point DFT. If r = 2, it is called
radix-2 FFT.
Code:-
clear; // Remove clear, clc from code if you want to access existing stored variable from
the memory
//Example 4.24
//Program to Compute the 8-point DFT of given Sequence
//x[n]=[0,1,2,3,4,5,6,7] using DIF, radix-2,FFT Algorithm.
clear;
clc ;
close ;
x = [0,1,2,3,4,5,6,7];
//FFT Computation
X = fft (x , -1);
disp(X,'X(z) = ');
clear; // Remove clear, clc from code if you want to access existing stored variable from
the memory
//Example 4.10
//Program to Compute the 4-point DFT of a Sequence x[n]=[0,1,2,3]
//using DIT-DIF Algorithm.
clear;
clc ;
close ;
x = [0,1,2,3];
//FFT Computation
X = fft (x , -1);
disp(X,'X(z) = ');
Output:-