Experiments1 5

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

Experiment No.

Aim:- Program to implement sampling and Reconstruction.

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.

Sampling is defined as, “The process of measuring the instantaneous values of


continuous-time signal in a discrete form.”

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.

Conclusion:- Thus we successfully studied operations of sampling and reconstruction


in digital signal processing.

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:-

Correlation is used to compare two signals. It is a measure of similarity between signals


and is found using a process similar to convolution. It occupies a significant role in
signal processing. It is used in radar and sonar systems to find the location of a target
by comparing the transmitted and reflected signals.

Other applications of correlation are in image processing, control engineering etc.


The correlation is of two types: (i) Cross correlation (ii) Auto-correlation.

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:

If the time shift n = 0, then we get


Comparing the above equations for Rxy(n) and Ryx(n), we observe that

where Ryx(– n) is the folded version of Ryx(n) about n = 0.

The expression for Rxy(n) 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.

Conclusion:- Thus we studied and implemented discrete correlation and cross


correlation.

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

- 6.9500035 - 7.2426034 - 7.5412364 - 7.8459023 - 8.1566013 - 8.4733332

column 7 to 12

- 8.7960981 - 9.124896 - 9.4597269 - 9.8005908 - 10.147488 - 10.500418

column 13 to 18

- 10.85938 - 11.224376 - 11.595405 - 11.972467 - 12.355562 - 12.744689

column 19 to 23

- 13.13985 - 13.541044 - 13.948271 - 14.361531 - 14.780823

Experiment No.3

Aim:- To perform Discrete Convolution.


Theory:-

Convolution is a mathematical operation equivalent to finite impulse response (FIR)


filtering.It is a method of finding the zero-state response of relaxed linear time-invariant
systems. It is important in digital signal processing because convolving two sequences
in time domain is equivalent to multiplying the sequences in frequency domain.

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)

Where y (t) = output of LTI

x (t) = input of LTI

h (t) = impulse response of LTI

are two types of convolutions:

● 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

Aim:- To perform Discrete Fourier transform.

Theory:-

In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of


equally-spaced samples of a function into a same-length sequence of equally-spaced
samples of the discrete-time Fourier transform (DTFT), which is a complex-valued
function of frequency.

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.

A real periodic discrete-time signal x(n) of period N can be expressed as a weighted


sum of complex exponential sequences. As the sinusoidal sequences are unique only
for digital frequencies from 0 to 2, the expansion has only a finite number of complex
exponentials.

The exponential form of the Fourier series for a periodic discrete-time signal is given
By

Conclusion:- Thus we studied and perform discrete fourier transform.

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.

By adopting a divide and conquer approach, a computationally efficient algorithm can


be developed. This approach depends on the decomposition of an N-point DFT into
successively smaller size DFTs. An N-point sequence, if N can be expressed as N =
r1r2r3, ..., rm

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, the r3

-point DFTs are computed and so on, until we get rm-point DFT. If r = 2, it is called
radix-2 FFT.

Conclusion:- Thus we studied and performed fast fourier transform.

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:-

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy