Digital Signal Processing Lab Manual
Digital Signal Processing Lab Manual
ECL-17
LABORATORY MANUAL
TABLE OF CONTENTS
S.NO. CONTENTS
3. PEO,PO,PSO,CO
4 CO-PO,PSO Mapping
5 RTU Syllabus
6 List of Experiments
9 Safety Measures
VISION OF INSTITUTE
To promote higher learning in advanced technology and industrial research to make our
country a global player
MISSION OF INSTITUTE
To promote quality education, training and research in the field of Engineering by
establishing effective interface with industry and to encourage faculty to undertake industry
sponsored projects for students
• Functional areas like teaching departments, Training & Placement Cell, library,
administrative office, accounts office, hostels, canteen, security services, transport,
maintenance section and all other services.”
VISION
“To evolve the department as a center of excellence in the field of electronics and
communication engineering for enriched education, higher learning, research and
development.”
MISSION
“To empower students by imparting quality education in electronics and communication
engineering for better employability and preparing them to be competent in dealing with
industrial and societal challenges.”
PROGRAM OUTCOMES
5. Modern tool usage: Create, select, and apply appropriate techniques, resources,
and modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
Course Outcomes :
After completion of this lab course, students will be able to -
C5EC22.2 Sketch the magnitude and phase response of DFT, Inverse DFT and FFT of
discrete time signals.
C5EC22.2 3 2 1 2 2 - - - - 3 - 3
C5EC22.3 3 2 1 2 2 - - - - 3 - 3
C5EC22.4 3 2 1 2 2 - - - - 3 - 3
C5EC22.5 3 3 1 3 2 - - - - 3 - 3
C5EC22 3 3 1 3 2 - - - - 3 - 3
CO-PSO Mapping
CO PSO1 PSO2
C5EC22.1 3 3
C5EC22.2 3 3
C5EC22.3 3 3
C5EC22.4 3 3
C5EC22.5 3 3
RTU SYLLABUS
following:
LIST OF EXPERIMENTS
Beyond
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
syllabus
5EC22A.a 3 3 3 - 3 3 - - - - - 3
3 3 3 3 - - - - - - - 3
5EC22A.b
INSTRUCTIONS OF LAB
DO’S
1. Student should get the record of previous experiment checked before starting the new
experiment.
2. Read the manual carefully before starting the experiment.
3. Before starting the experiment, system checked by the teacher.
4. Get your readings checked by the teacher.
5. Apparatus must be handled carefully.
6. Maintain strict discipline.
7. Keep your mobile phone switched off or in vibration mode.
8. Students should get the experiment allotted for next turn, before leaving the lab.
DON’TS
1. Do not touch or attempt to touch the mains power supply wire with bare hands.
2. Do not overcrowd the tables.
3. Do not tamper with equipments.
4. Do not leave the lab without permission from the teacher.
SAFETY MEASURES
1. Antivirus software is installed for protection against viruses and malwares.
2. External storage devices are not allowed to use in lab.
3. At all the times the right procedures while starting and shutting down the computer
therefore abrupt switching on and off the computer should be avoided since this can
lead to damaging the computer.
4. Any repairs to the computer should be done by someone who has knowledge
regarding computer repairs.
INTRODUCTION TO SCILAB
OBJECTIVE OF LAB:
say that in 0 and 1 form. This makes the processing fast and immune to the noise. Digital
Signal Processors (DSP) take real-world signals like voice, audio, video, temperature, pressure, or
positions that have been digitized and then mathematically manipulate them. A DSP is designed for
performing mathematical functions like "add", "Subtract", "multiply" and "divide" very quickly.
Signals need to be processed so that the information that they contain can be displayed, analyzed, or
converted to another type of signal that may be of use. In the real-world, analog products detect
signals such as sound, light, temperature or pressure and manipulate them. Converters such as an
Analog-to-Digital converter then take the real-world signal and turn it into the digital format of 1's and
0's. From here, the DSP takes over by capturing the digitized information and processing it. It then
feeds the digitized information back for use in the real world. It does this in one of two ways, either
digitally or in an analog format by going through a Digital-to-Analog converter. All of this occurs at
very high speeds.
This lab will teach the basics concepts involve in the digital processing of signals. It includes
many different topics, such as:
• filters
• analysis of signals and systems
• synthesis of signals
• Behavior of LTI systems
• Random sequence like Rayleigh distribution, Gaussian distribution etc.
•
SCOPE:
In the UG level projects one can design the system by applying the knowledge of DSP. This lab helps
to understand all the conditions of processing the signal.
Also in higher studies, the dissertation work includes the area of digital signal processing and image
processing speech processing, FPGA programming etc. so strong knowledge of DSP is needed.
Once the basic DSP background is in place, many application-specific DSP areas are
accessible. This includes speech processing (recognition, synthesis, and compression), image
processing, audio processing (analysis, synthesis, etc.), and all types of biomedical signal
processing, and on and on.
ADVANTAGES OF DSP :
1. High Accuracy: The accuracy of the analog filter is affected by the tolerance of the circuit
components used for designing the filter, but DSP has superior control of accuracy.
2. Cheaper: The digital realization is much cheaper than the analog realization in many applications.
5. Time Sharing: The cost of the processing signal can be reduced in DSP by the sharing of a given
processor among a number of signals.
1. Telecommunication
2. Consumer Electronics
3. Image Processing
5. Military Applications
6. Speech Processing
7. Seismology
8. Medicine
LEARNING OBJECTIVES:
EXPERIMENT NO: 1
AIM: To generate continuous and discrete time unit Impulse, unit step and unit ramp
signals using mathematical expressions
THEORY: A unit step signal has magnitude 1 for time greater than or equal to zero. We can
assume it as a dc signal which got switched on at time equal to zero. Unit step signal is a basic
signal and is denoted by u (t) or u(n). This function is defined as.
Ramp signal: A ramp signal is a signal whose magnitude increases along with time. It can
be obtained by integrating unit step signal.
Impulse Signal: An ideal impulse function is a function that is zero everywhere except
origin, and at origin it is infinitely high. The unit impulse function has zero width, infinite
height and area under the curve is unity.
PROGRAM:
clc;
clear;
else yc(i)=0;
end
end
subplot (2,3,4)
plot (t,yc)
xlabel("Time")
ylabel("Amplitude")
OUTPUT:
Figure 1.6: Continuous and discrete time Impulse, Step and Ramp Signal
RESULT:-Impulse, Step and Ramp signals in Continuous & Discrete domain have been
plotted as shown in Fig 1.6. These signals have been plotted using their mathematical
expressions.
DISCUSSION:
1. What are the practical applications of unit step function.
2. Differentiate between unit step and unit impulse function.
3. Draw y(t)= u(t+2)- u (t-2)
4. Draw y(t)= 2u(n+1) – u(n-1)
5. What are Exponential and Ramp signals?
6. What are stable and unstable signals?
\\
EXPERIMENT NO: 2
AIM: To Perform basic operations on signals like adding and subtracting, shifting and scaling
THEORY:
The first and foremost operation which we will consider will be addition. The addition of
signals is very similar to traditional mathematics. That is, if x1(t) and x2(t) are the two
continuous time signals, then the addition of these two signals is expressed as x1(t) + x2(t).
The resultant signal can be represented as y(t) from which we can write
y(t) = x1(t) + x2(t)
Similarly, for discrete time signals, x1[n] and x2[n], we can write
y[n] = x1[n] + x2[n]
Similar to the case of addition, subtraction deals with the subtraction of two or more signals
in order to obtain a new signal.
Mathematically it can be represented as
y(t) = x1(t)- x2(t) for continuous time signals, x1(t) and x2(t)
y[n] = x1[n] - x2[n] for discrete time signals, x1[n] and x2[n]
Time Shifting: The time-shifting operation results in the change of just the positioning of
the signal without affecting its amplitude or span.
Time-Delayed Signals: This signal is shifted to right side of the origin
y[n] = x[n-k].
This kind of signal is referred to as time-delayed because the signal arrives late compared to
the original signal.
Time-Advanced Signals: This signal is shifted to left side of the origin signal.
y[n] = x[n+k].
This kind of signal is referred to as time-delayed because the signal arrives earlier than
original signal.
Time Reversal: It results in the reflection of the signal along its vertical axis of reference. As
a result, the operation is known as the time reversal or time reflection of the signal.
PROGRAM:
clc ;
clear all;
close ;
t = -1:0.1:5;
x1 = 1;
x2 = 2;
x3 = 3- t ;
xa = x1 .*( t >0 & t <1) + x2 .*( t >=1 & t <=2) + x1 .*( t >2& t <3) ;
xb = t .*( t >0 &t <1) + x1 *( t >=1 &t <=2) + x3 .*( t >2 &t <3) ;
xadd = xa + xb ;
xmul = xa - xb ;
subplot (2 ,3 ,1) ;
plot2d3 (t , xa ) // P l o t s i n p u t s i g n a l xa
xlabel ( 't') ;
ylabel ( 'Ampli tude') ;
title ( 'input signal xa') ;
subplot (2 ,3 ,2) ;
plot2d3 (t , xb ) // P l o t s i n p u t s i g n a l xb
xlabel ( 't' ) ;
ylabel ('Ampli tude') ;
title ('input signal xb') ;
subplot (2 ,3 ,3) ;
plot2d3 (t , xadd ) // P l o t s a d d i t i o n of s i g n a l xa andxb
xlabel ('t') ;
ylabel ('Ampli tude') ;
title ('Addition of two signals, xadd') ;
subplot (2 ,3 ,4) ;
plot2d3 (t , xmul ) // P l o t s Subtraction of s i g n a l xaand xb
xlabel ( 't') ;
ylabel ('Ampli tude') ;
title ('Subtraction of two signals, xmul') ;
OUTPUT
PROGRAM
// Program to demostrate the shifting of the discrete time signal
clc ;
clear ;
close ;
x = input ('Rnter the input sequence:=')
m = length ( x ) ;
lx = input ('Enter the starting point of original signal:=' )
hx = lx +m -1;
n = lx :1: hx ;
subplot (3 ,1 ,1)
a = gca () ;
a . x_location ="origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , x );
xlabel ('n===>')
ylabel ('Amplitdue−−−>')
title ('original sequence')
d = input ('Enter the delay:=')
n = lx + d :1: hx + d ;
subplot (3 ,1 ,2)
a = gca () ;
a . x_location = "origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , x)
xlabel ('n===>')
ylabel ('Amplitude−−−>' )
title ('Delayed Sequence')
a = input ('Enter the advance :=')
n = lx - a :1: hx - a ;
Department of ECE Page 25
Digital Signal Processing Lab
subplot (3 ,1 ,3)
a = gca () ;
a . x_location = "origin";
a . y_location = "origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , x)
xlabel ( 'n===>')
ylabel ( 'Amplitude−−−>')
title ( 'Advanced Sequence')
OUTPUT
PROGRAM
// Program to demonstrate amplitude and time scaling of a signal
clc ;
clear ;
x = input ('Enter input sequence:=') ;
m = length ( x ) ;
lx = input ('Enter starting point of original sequence:=')
hx = lx +m -1;
n = lx :1: hx ;
subplot (2 ,2 ,1);
a = gca () ;
a . x_location ="origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , x );
xlabel ('n====>');
ylabel ('Amplitude−−−−>');
title ('original sequence');
// Ampli tude S c a l i n g
a = input('Amplitude Scaling factor:=');
y=a*x;
subplot (2 ,2 ,2)
a = gca () ;
a . x_location = "origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , y);
xlabel ('n====>');
ylabel ('Amplitdue−−−−>');
title ('Amplitude scaled sequence');
//Time S c a l i n g −Com p r e s sio n
C = input('Enter compression factor −time scaling factor')
n = lx / C :1/ C : hx / C ;
subplot(2 ,2 ,3);
a = gca () ;
a . x_location ="origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn',n , x);
xlabel ('n===>');
ylabel ('Amplitude−−−>');
title ('Compressed sequence');
//Time S c a l i n g −E x pa n sio n
d = input('Time scaling factor');
n = lx * d: d : hx * d ;
subplot(2 ,2 ,4)
a = gca () ;
a . x_location ="origin";
Department of ECE Page 27
Digital Signal Processing Lab
a . y_location = "origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ( 'gnn' ,n , x);
xlabel ('n===>');
ylabel ('Amplitude−−−>');
title ('Extended sequence');
OUTPUT:
RESULT:-
The output of addition, subtraction and shifting and time scaling operations for the given
discrete time signals is shown in Fig 2.1, 2.2, 2.3.
DISCUSSION:
1. What is the importance of scaling and shifting in digital signal processing?
2. Explain Interpolation and Decimation.
3. How Digital Signal Processing is better than Analog Signal Processing?
EXPERIMENT NO:3
AIM: Perform Continuous and discrete time Convolution (using basic definition).
THEORY:
Convolution:
Convolution is defined as an operation which helps to find the output of the LTI (linear and
time-invariant) system when the impulse response of the system and the input signal are
known.
(Impulse response is defined as behavior of system under unit impulse signal which is defined
for t=0 only)
(a)
(b)
Figure 3.1 LTI system with output represented as convolution between input and
impulse response
a) Continuous time system (b) discrete time system
If a continuous-time system is both linear and time-invariant, then the output Y(t) is related to
the input X(t) and impulse response (h(t)) of the system by the equation given below:
:
(4.1)
Equation 4.1 is also known as convolution integral between X(t) and h(t)
Similarly, if a discrete-time system is both linear and time-invariant, then the output Y(n) is
related to the input X(n) and impulse response (h(n)) of the system by the equation mentioned
below:
(4.2)
PROGRAM:
//C o n v ol u ti o n Sum of i n p u t s e q u e n c e x [ n]= (2ˆ n ) . u[−n ] and h [ n ] = u [ n ]
PROGRAM
clear ;
close ;
clc ;
Max_Limit = 10;
h = ones (1 , Max_Limit ) ;
N2 =0: length ( h ) -1;
for n = 1: Max_Limit
x1 ( n) = (2^( -( n -1) ) ) *1;
end
x = x1 ( $ : -1:1) ;
N1 = -length ( x ) +1:0;
y = convol (x , h ) ;
N = -length ( x ) +1: length ( h ) -1;
subplot(2,2,1);
plot2d3 ('gnn' ,N2 ,h )
xtitle ('Im p ul s e R e s po n s e ’ , ’ n ’ , ’ h [ n ]') ;
subplot(2,2,2);
plot2d3 ('gnn',N1 ,x )
xtitle ('I n p u t R e s po n s e Fig 2 . 1 1 ( a ) ’ , ’ n ’ , ’ x [ n ]') ;
subplot(2,2,3);
plot2d3 ('gnn',N , y)
xtitle ('Output R e s po n s e Fig 2 . 1 1 ( b ) ’ , ’ n ’ , ’ y [ n ]') ;
OUTPUT
Fig 3.2 Discrete time convolution a) Impulse Response b) Input response c) Convolved
output
PROGRAM
subplot(2,2,2)
plot2d ( N1 , x )
xtitle ('I n p u t R e s po n s e ’ , ’ t ’ , ’ x ( t )') ;
subplot(2,2,3)
plot2d ( N (1: Max_Limit ) ,y (1: Max_Limit ) )
xtitle ('Output R e s po n s e ’ , ’ t ’ , ’ y ( t )') ;
OUTPUT
RESULT:-
The output of discrete LTI System with for x [ n]= (2ˆ n ) . u[−n ] and h [ n ] = u [ n ]
is as shown in figure 3.2(c)
The output of continuous LTI System with x ( t ) = (eˆ−a t ) . u ( t ) and h ( t ) =u ( t )
shown in figure 3.3 (c)
DISCUSSION:
1) Differentiate between linear and circular convolution.
2) Determine the unit step response of the linear time invariant system with impulse
response
3) Determine the range of values of the parameter a for which linear time
invariant system with impulse response is stable.
4) Describe impulse response of a function and its importance
EXPERIMENT-4
AIM: Write a program to check Linearity and Time variance property of a system using
convolution, shifting
THEORY:
1. LINEARITY PROPERTY:. Changing the input in a linear way will change the
output in the same linear way. So if the input x(t) produces the output y(t) then input
ax(t) will produce the output ay(t) where a is any constants.
So,
If y(t)=x(t)*h(t)
then ax(t)*h(t)= ay(t)
PROGRAM:
//To c h e c k w h e t h e r t h e g i v e n d i s c r e t e s y s t em i s aL i n e a r System ( o r )
Non−L i n e a r System
// Given d i s c r e t e s y s t em y ( t )= t ∗x ( t )
clear ;
clc ;
x1 = [1 ,1 ,1 ,1];
x2 = [2 ,2 ,2 ,2];
a = 1;
b = 1;
for t = 1: length ( x1 )
x3 ( t ) = a * x1 ( t ) + b* x2 ( t ) ;
end
for t = 1: length ( x1 )
y1 ( t) = t * x1 ( t ) ;
y2 ( t) = t * x2 ( t ) ;
y3 ( t) = t * x3 ( t ) ;
end
for t = 1: length ( y1 )
z ( t ) = a* y1 ( t ) + b * y2 ( t ) ;
end
count = 0;
for n =1: length ( y1 )
Department of ECE Page 35
Digital Signal Processing Lab
if( y3 ( t ) == z ( t ) )
count = count +1;
end
end
if( count == length ( y3 ) )
disp ('S i n c e I t s a t i s i f i e s t h e s u p e r p o s i t i o np r i n c i p l e')
disp ('The g i v e n s y s t em i s a L i n e a r s y s t em')
y3
z
else
disp ('S i n c e I t d o e s no t s a t i s i f y t h es u p e r p o s i t i o n p r i n c i p l e')
disp ('The g i v e n s y s t em i s a Non−L i n e a r s y s t em')
end
OUTPUT
"Since it satisfy the superposition principle"
PROGRAM
//To c h e c k w h e t h e r t h e g i v e n d i s c r e t e s y s t em i s aL i n e a r System ( o r )
Non−L i n e a r System
// Given d i s c r e t e s y s t em y [ n ] )= 2∗ x [ n]+3
clear ;
clc ;
x1 = [1 ,1 ,1 ,1];
x2 = [2 ,2 ,2 ,2];
a = 1;
b = 1;
for n = 1: length ( x1 )
x3 ( n ) = a * x1 ( n ) + b* x2 ( n ) ;
end
for n = 1: length ( x1 )
y1 ( n ) = 2* x1 ( n ) +3;
y2 ( n ) = 2* x2 ( n ) +3;
y3 ( n ) = 2* x3 ( n ) +3;
end
for n = 1: length ( y1 )
z ( n ) = a* y1 ( n ) + b * y2 ( n ) ;
end
count = 0;
for n =1: length ( y1 )
if( y3 ( n ) == z ( n ) )
count = count +1;
end
end
if( count == length ( y3 ) )
OUTPUT
"Since it does not satisfy the superposition principle"
PROGRAM
//To c h e c k w h e t h e r t h e g i v e n s y s t em i s a Timev a r i a n t ( o r ) Time In−v a r i a
nt
// The g i v e n d i s c r e t e s i g n a l i s y ( t ) = x (2 t )
clear ;
clc ;
to = 2; //Assume t h e amount of tim e s h i f t =2
T = 10; // Leng th of g i v e n s i g n a l
x = [1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10];
y = zeros (1 , length ( x ) ) ;
for t = 1: length (x ) /2
y ( t ) = x (2* t ) ;
end
// F i r s t s h i f t t h e i n p u t s i g n a l o nl y
Input_shift = x (T - to ) ;
Output_shift = y (T - to ) ;
if( Input_shift == Output_shift )
disp ('The g i v e n d i s c r e t e s y s t em i s a Time In−v a r i a n t s y s t em') ;
else
disp ('The g i v e n d i s c r e t e s y s t em i s a Time V a ri a n ts y s t em ') ;
end
OUTPUT
"The given discrete system is a time variant system "
PROGRAM
//To c h e c k w h e t h e r t h e g i v e n s y s t em i s a Timev a r i a n t ( o r ) Time In−v a r i a
nt
// The g i v e n d i s c r e t e s i g n a l i s y [ n ] = x [ n ]
clear ;
clc ;
no = 2; //Assume t h e amount of tim e s h i f t =2
L = 10; // Leng th of g i v e n s i g n a l
for n = 1: L
x ( n ) = n;
y ( n ) = n* x ( n ) ;
end
// F i r s t s h i f t t h e i n p u t s i g n a l o nl y
Input_shift = x (L - no ) ;
Output_shift = y (L - no ) ;
if( Input_shift == Output_shift )
disp ('The g i v e n d i s c r e t e s y s t em i s a Time In−v a r i a n t s y s t em') ;
else
disp ('The g i v e n d i s c r e t e s y s t em i s a Time V a ri a n ts y s t em') ;
end
OUTPUT:
"The given discrete system is time variant system"
RESULT: The response for time shifting and linearity property has been shown in figure 4.1.
DISCUSSION:
1) Differentiate between linear and circular convolution.
2) What is LTI System?
3) State the Linearity and Time Invariant property of a signal.
4) Describe impulse response of a function and its importance.
EXPERIMENT NO: 5
AIM: To generate and verify random sequences with arbitrary distributions, means and
variances for following:
(a) Rayleigh distributions
(b) Normal distributions: N (0,1).
(c) Gaussian distributions: N (m, x)
(d) Random binary wave.
THEORY:
The term random signal is used primarily to denote signals, which have a randomness in its
nature source. As an example we can mention the thermal noise, which is created by the
random movement of electrons in an electric conductor.
Random signals are those signals whose behavior cannot be predicted using any past
reference.
Random signals are those that do not repeat with any definite sequence, but rather must be
described in terms of some probability. The characteristics of random signal are primarily
determined by its probability distribution function (PDF). There are many types of PDF
available to characterize the behavior of random signals as:
1. Gaussian distribution
2. Rayleigh distribution
3. Gamma distribution
4. Uniform Distribution
And many more……..
In this experiment we are mainly concerned about three types of distribution i.e.
1. Gaussian distribution
2. Rayleigh distribution
3. Normal distribution
Gaussian Distribution:
Gaussian distribution (also known as normal distribution) is a bell-shaped curve, and it is
assumed that during any measurement values will follow a normal distribution with an
equal number of measurements above and below the mean value.
The PDF of Gaussian distribution of random signal x is
: variance of the PDF, is the standard deviation, : mean of the PDF. The
2. Normal Distribution:
Gaussian distribution with mean =0 and variance=1, is known to be standard normal
distribution. The PDF of normal distribution is:
3. Rayleigh Distribution:
In probability theory and statistics, the Rayleigh distribution is a continuous probability
distribution for nonnegative-valued random variables. Wireless channel communication and
its related fading problem is generally characterized by Rayleigh distribution.
; x>0
MEAN = 0;
VAR=1;
u=exp(-(X-MEAN)^2/(2*VAR^2))/(2*%pi*VAR^2)^0.5
subplot(3,1,2);
plot(X,u);
xlabel("X");
ylabel("PDF");
title("Normal Distribution curve");
P=0:0.01:20;
var2=input("Enter the variance of the signal : ");
px=P.*exp(-(P^2/(2*var2^2)))/var2^2;
subplot(3,1,3);
plot(P,px);
xlabel("X");
ylabel("PDF");
title("Rayleigh Distribution curve");
OUTPUT
PROGRAM
//SWITCH CASE:
clc
clear
i=1
while(i==1)
disp('enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random binary wave');
c=input('Enter your choice')
switch(c)
case 1
x=-5:0.01:5;
mean=2;
var=2
px=(exp(-((x-mean)^2)/(2*var*var)))/((2*%pi*var*var)^0.5);
figure
subplot(1,4,1)
plot(x,px)
case 2
x=-5:0.01:5;
mean=0;
var=1
px=(exp(-((x-mean)^2)/(2*var*var)))/((2*%pi*var*var)^0.5);
figure
subplot(1,4,2)
plot(x,px)
case 3
x=0:0.01:5;
r=2;
pr=(x/(r^2)).*exp(-x.*x/(2*r*r)) ;
figure
subplot(1,4,3)
plot(x,pr)
case 4
figure
y=prbs_a(20,7);
subplot(1,4,4)
plot2d2(y)
end
end
OUTPUT:
enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random bina ry wave
Enter your choice1
do you want to continue press 1 and 0 for exit 1
1
Fig 5.5 (a) Gaussian Distribution
enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random binary wave
Enter your choice2
enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random binary wave
Enter your choice3
do you want to continue press 1 and 0 for exit 1
enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random binary wave
Enter your choice4
do you want to continue press 1 and 0 for exit 0
RESULT:-
The different probability distributions have been computed for specified parameters and the
pdfs of Gaussian, normal and random binary waves is shown in figure 5.4 & 5.5 respectively.
DISCUSSION:-
1. Define AWGN and how its useful in communication system?
2. What does the variance of Gaussian distribution specify?
3. What does the mean of probability distribution function specify?
4. Which random data is modeled by Gaussian and Rayleigh probability distribution?
EXPERIMENT NO: 6
THEORY:
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 interval at which
the DTFT is sampled is the reciprocal of the duration of the input sequence.
The DFT is the most important discrete transform, used to perform Fourier analysis in many
practical applications. In digital signal processing, the function is any quantity or signal that
varies over time, such as the pressure of a sound wave, a radio signal, or
daily temperature readings, sampled over a finite time interval.
PROGRAM:
clf;
clear;
N=length(x);
y=0:N-1;
r=0:N-1;
W=exp(-%i*2*%pi*y'*r/N);
X=x*W;
mag=abs(X);
phase=atan(imag(X),real(X));
subplot(2,2,1);
plot2d3(r,x);
xlabel('n');
ylabel('x(n)');
title('Input Signal');
subplot(2,2,2);
plot2d3(r,mag);
xlabel('k');
ylabel('X(k)');
title('Magnitude of X(k)');
subplot(2,2,3);
plot2d3(r,phase);
xlabel('k');
ylabel('X(k)');
title('Phase of X(k)');
W1=exp(%i*2*%pi*y'*r/N);
X1=X*W1;
mag1=abs(X1);
subplot(2,2,4);
plot2d3(r,mag1);
xlabel('k');
ylabel('X(k)');
title('IDFT signal');
OUTPUT
Enter the discrete time sequence: [1 2 3 4]
RESULT: The DFT and IDFT phase and magnitude response is shown in Fig 6.1
DISCUSSION:
1. What is the difference between DTFT and DFT?
2. What is the need to study DFT Signal?
3. How the DTFT signal is converted into DFT?
4. List the important properties of DFT
EXPERIMENT NO: 7
THEORY:
A fast Fourier transform (FFT) is an efficient algorithm to compute the discrete Fourier
transform (DFT) and its inverse. FFTs are of great importance to a wide variety of
applications, from digital signal processing and solving partial differential equations to
algorithms for quick multiplication of large integers. Evaluating the sums of DFT directly
would take O(N 2) arithmetical operations. An FFT is an algorithm to compute the same
result in only O(N log N) operations. In general, such algorithms depend upon the
factorization of N, but there are FFTs with O(N log N) complexity for all N, even for
prime N. Since the inverse DFT is the same as the DFT, but with the opposite sign in the
exponent and a 1/N factor, any FFT algorithm can easily be adapted for it as well
For FFT.
The no of multiplication = N/2 log 2N.
The no of additions = N log2 N.
PROGRAM:
clc ;
clear ;
// Le t x ( n ) ={ 1 , 2 , 1 , 2 , 0 , 2 , 1 , 2 }
// Le t u s b e gi n wi t h t h e programming . Foru n d e r s t a n di n g , l e t u s w r i t e t h e g
i v e n da ta a s
// x ( 0 ) =1; x ( 1 ) =2,x ( 2 ) =1,x ( 3 ) =2,x ( 4 ) =0,x ( 5 ) =2,x ( 6 ) =1,x( 7 )=2
x0 =1; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x4 =0; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x2 =1; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x6 =1; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x1 =2; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x5 =2; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x3 =2; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x7 =2; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
// S t a g e I com p u ta tio n
x0a = x4 + x0 ; // Computing S tage−I o u t p u t a t l i n e 1
disp ( x0a ,"S tage−I o u t p u t a t l i n e 1=")
x4b =( x4 - x0 ) *( -1) ; // Computing S tage−I o u t p u t a t l i n e
disp ( x4b ,"S tage−I o u t p u t a t l i n e 2=")
x2c = x6 + x2 ; // Computing S tage−I o u t p u t a t l i n e 3
disp ( x2c ,"S tage−I o u t p u t a t l i n e 3=")
x6d =( x6 - x2 ) *( -1) ; // Computing S tage−I o u t p u t a t l i n e
disp ( x6d ,"S tage−I o u t p u t a t l i n e 4=")
x1e = x5 + x1 ; // Computing S tage−I o u t p u t a t l i n e 5
disp ( x1e ,"S tage−I o u t p u t a t l i n e 5=")
x5f =( x5 - x1 ) *( -1) ; // Computing S tage−I o u t p u t a t l i n e
disp ( x5f ,"S tage−I o u t p u t a t l i n e 6=")
x3g = x7 + x3 ; // Computing S tage−I o u t p u t a t l i n e 7
disp ( x3g ,"S tage−I o u t p u t a t l i n e 7")
x7h =( x7 - x3 ) *( -1) ; // Computing S tage−I o u t p u t a t l i n e
disp ( x7h ,"S tage−I o u t p u t a t l i n e 8=")
// S tage−I o u t p u t a t l i n e 4 and l i n e 8 i s to bem u l t i p l i e d by t w i d d l e f a c t o r
ha vi ng v a l u e (− j )
x6d1 =( x6d ) *( - sqrt ( -1) ) ;
x7h1 =( x7h ) *( - sqrt ( -1) ) ;
disp ( x6d1 ,"S tage−I o u t p u t ( i . e . i n p u t to s t a g e −I I )a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r v a l u e of(− j ) a t l i n e 4 =")
disp ( x7h1 ,"S tage−I o u t p u t ( i . e . i n p u t to s t a g e −I I )a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r v a l u e of(− j ) a t l i n e 8 =")
// S tage−I I Compu ta tion s
x0a_stageII_output = x2c + x0a ; // Computing S tage−I Io u t p u t a t l i n e 1
disp ( x0a_stageII_output ,"S tage−I I o u t p u t a t l i n e 1=")
x4b_stageII_output = x6d1 + x4b ; // Computing S tage−I Io u t p u t a t l i n e 2
disp ( x4b_stageII_output ,"S tage−I I o u t p u t a t l i n e 2=")
x2c_stageII_output =( x2c - x0a ) *( -1) ; // Computing S tage−I I o u t p u t a t l i n e 3
Department of ECE Page 52
Digital Signal Processing Lab
OUTPUT:-
S tage−I o u t p u t a t l i n e 1=
1.
S tage−I o u t p u t a t l i n e 2=
1.
S tage−I o u t p u t a t l i n e 3=
2.
S tage−I o u t p u t a t l i n e 4=
0.
S tage−I o u t p u t a t l i n e 5=
4.
S tage−I o u t p u t a t l i n e 6=
0.
S tage−I o u t p u t a t l i n e 7
4.
S tage−I o u t p u t a t l i n e 8=
0.
S tage−I o u t p u t ( i . e . i n p u t to s t a g e −I I )a f t e r m u
l t i p l i c a t i o n by t w i d d l e f a c t o r v a l u e of(− j )
atline4=
0.
S tage−I o u t p u t ( i . e . i n p u t to s t a g e −I I )a f t e r m u
l t i p l i c a t i o n by t w i d d l e f a c t o r v a l u e of(− j )
atline8=
0.
S tage−I I o u t p u t a t l i n e 1=
3.
S tage−I I o u t p u t a t l i n e 2=
1.
S tage−I I o u t p u t a t l i n e 3=
-1.
S tage−I I o u t p u t a t l i n e 4=
1.
S tage−I I o u t p u t a t l i n e 5=
8.
S tage−I I o u t p u t a t l i n e 6=
0.
S tage−I I o u t p u t a t l i n e 7=
0.
S tage−I I o u t p u t a t l i n e 8=
0.
S tage−I I o u t p u t a tl i n e 6 a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r=
0.
S tage−I I o u t p u t a tl i n e 7 a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r=
0.
S tage−I I o u t p u t a tl i n e 8 a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r=
0.
X( 0 )=
11.
X( 1 )=
1.
X( 2 )=
-1.
X( 3 )=
1.
X( 4 )=
-5.
X( 5 )=
1.
X( 6 )=
-1.
X( 7 )=
1.
RESULT:
DISCUSSION:
1. Differentiate Fourier transform and discrete Fourier transform
2. Differentiate DFT and DTFT.
3. What are the advantages of FFT over DFT?
4. What is meant by twiddle factor and give its properties?
5. Compare FFT and DFT with respect to number of calculation required?
6. How the original signal is reconstructed from the FFT of a signal?
EXPERIMENT NO: 8
THEORY:
Circular convolution resembles the linear convolution, except that the sample values of one
of the input signals is folded and right shifted before the convolution sum is found.
Also circular convolution could also be found by taking the DFT of the two
input signals and finding the product of the two frequency domain signals. The
Inverse DFT of the product would give the output of the signal in the time domain
which is the circular convolution output. The two input signals could have been of
varying sample lengths.
Circular convolution resembles the linear convolution, except that the sample values of one
of the input signals is folded and right shifted before the convolution sum is found.
It is expressed as matrix multiplication. Here an N*N matrix is set up whose columns are
equal to sequence and its cyclically shifted versions. This is called circulant matrix. An N*N
circulant matrix C for x(n) has general form
This matrix is multiplied with transpose of 2nd input matrix to find circularly convolved
output
PROGRAM:
OUTPUT
RESULT:
ENTER THE FIRST SEQUENCE [ us e s qu a r eb r a ck e t − a r r a y form ]=[1 2 3 4 5 6 4]
"C i r c u l a r c o n v o l u t i o n i s ="
DISCUSSION:
EXPERIMENT NO: 9
THEORY:
Z transform is used to convert time domain signal into Z-domain. Z-domain is the complex
frequency plane and is used to find the frequency response of signals. It is the generalized
form of converting discrete time domain into frequency domain. It’s related to DTFT
(Discrete time Fourier Transform) in which DTFT obtained signal is multiplied by a
converging factor to make it stable in the desired range of frequency. The Z-transform of
signal x(n) is defined as:
In MATLAB ztrans() and iztrans() are used to find the z-transpose and inverse Z-transpose
respectively.
PROGRAM:
clc;
clear;
x = input("Enter the discrete signal : ");
Z=poly(0,"z");
n=0:length(x)-1;
X=x.*Z^-n;
Xz=sum(X);
disp("Z transform of the signal is :");
disp(Xz);
disp("ROC of the signal is entire Z plane except 0");
t=length(x)-1;
num=9+Z+6*Z^2+3*Z^3;
den = Z^t;
y=ldiv(num,den,4);
disp("Inverse Z transform of the signal is : ");
disp(y’);
RESULT:
Enter the discrete signal : [3,6,2,8]
3. 6. 1. 9.
DISCUSSION:
EXPERIMENT 10
THEORY:
Z transform is used to convert time domain signal into Z-domain. Z-domain is the complex
frequency plane and is used to find the frequency response of signals. It is the generalized
form of converting discrete time domain into frequency domain. It’s related to DTFT
(Discrete time Fourier Transform) in which DTFT obtained signal is multiplied by a
converging factor to make it stable in the desired range of frequency. The Z-transform of
signal x(n) is defined as:
We can evaluate the inverse z transform via Cauchy’s residue theorem which states that
x[n] = = ]
)= z = λk
Cauchy’s residue theorem allows to compute the contour integral by computing derivatives.
PROGRAM:
clc;
clear;
x = input("Enter the discrete signal : ");
Z=poly(0,"z");
n=0:length(x)-1;
X=x.*Z^-n;
Xz=sum(X);
disp("Z transform of the signal is :");
disp(Xz);
disp("ROC of the signal is entire Z plane except 0");
t=length(x)-1;
num=9+Z+6*Z^2+3*Z^3;
den = Z^t;
y=ldiv(num,den,4);
disp("Inverse Z transform of the signal is : ");
disp(y’);
OUTPUT
Enter the discrete signal : [3,6,2,8]
3. 6. 1. 9.
DISCUSSION:
EXPERIMENT NO: 11
THEORY: Analog filters are made up of resistors, capacitors, o-amps to produce required
output. These are mainly of two types:
1. Butterworth Filter
Butterworth filters are causal in nature and of various orders, the lowest order
being the best (shortest) in the time domain, and the higher orders being better in the
frequency domain. Butterworth or maximally flat filters have a monotonic amplitude
frequency response which is maximally flat at zero frequency response and the
amplitude frequency response decreases logarithmically with increasing frequency.
A Butterworth filter is characterized by its magnitude frequency response,
where N is the order of the filter and Ωc is defined as the cutoff frequency where the filter
magnitude is 1/√2 times the dc gain (Ω=0).
PROGRAM
fcut = 7; //hz
n = 7; // Filter order
hc1 = analpf(n, 'cheb1', [0.1 0], fcut*2*%pi);
hc2 = analpf(n, 'cheb2', [0 0.1], fcut*2*%pi);
he = analpf(n, 'ellip', [0.1 0.1], fcut*2*%pi);
hb = analpf(n, 'butt', [0 0], fcut*2*%pi);
clf();
[fr, hf] = repfreq(hc1, 0, 15);
plot(fr, abs(hf), 'b')
[fr, hf] = repfreq(hc2, 0, 15);
plot(fr,abs(hf),'g')
[fr, hf] = repfreq(he, 0, 15);
plot(fr,abs(hf),'r')
[fr, hf] = repfreq(hb, 0, 15);
RESULT:
The frequency response of analog low pass Low Pass Chebyshev I", "Chebyshev II",
"Elliptic", "Butterworth” are shown in Fig. 11.2
DISCUSSION:
1. List some advantages of digital filters over analog filters.
2. Write some differences between FIR and IIR filters.
3. What are the different methods to design IIR filters?
4. Why IIR filters are not reliable?
5. What are different applications of IIR filters?
6. What are advantages of IIR filters?
7. Differentiate Butterworth and Chebyshev approximations.
8. What is meant by impulse response?
EXPERIMENT NO: 12
AIM: To design FIR filter (LP/HP) using windowing (rectangular, triangular, kaiser)
technique.
THEORY:
Finite Impulse Response (FIR) Filters designed by using finite samples of Impulse response
are called FIR Filters. For the designing of Finite filters, windows of finite duration are used.
The windows are used to modify the impulse response of FIR filters in order to reduce the
ripples in the passband and stopband.
The different types of window sequence to design the FIR filter are as below:
1. Rectangular window
2. Triangular window
3. Raised Cosine windows
4. Hanning window
5. Hamming window
6. Kaiser window
1. Rectangular window
Rectangular window is defined as finite response of window that shows the
rectangular window
Alternatively,
Alternatively,
Where
Alternatively,
Where and
The parameter ‘a’ is an independent variable that can be varied to control the side lobe level
with respect to main-lobe peak. With increase in value of a the magnitude of first side lobe
reduces.
Where is calculated as .
PROGRAM
clc;
close all;
clear all;
rp=input('enter passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter passband freq');
fs=input('enter stopband freq');
f=input('enter sampling freq ');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
c=input('enter your choice of window function 1. rectangular
2. triangular 3.kaiser: \n ');
if(c==1)
y=rectwin(n1);
disp('Rectangular window filter response');
end
if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end
if(c==3)
y=kaiser(n1);
disp('kaiser window filter response');
end
%LPF
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);plot(o/pi,m);
title('LPF');
ylabel('Gain in dB-->');
xlabel('(a) Normalized frequency-->');
%HPF
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
title('HPF');
ylabel('Gain in dB-->');
xlabel('(b) Normalized frequency-->');
OUTPUT
enter passband ripple0.02
enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
1
LPF
20
-20
Gain in dB-->
-40
-60
-80
-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalized frequency-->
HPF
20
0
Gain in dB-->
-20
-40
-60
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalized frequency-->
LPF
0
-10
-20
Gain in dB-->
-30
-40
-50
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalized frequency-->
HPF
0
-5
-10
Gain in dB-->
-15
-20
-25
-30
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalized frequency-->
LPF
20
-20
Gain in dB-->
-40
-60
-80
-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalized frequency-->
HPF
20
0
Gain in dB-->
-20
-40
-60
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalized frequency-->
RESULT:
The response for LP and HP FIR Filter using Rectangular, Triangular and Kaiser window
have been shown in figures 12.1, 12.2 and 12.3 respectively for the sampling frequency
10000 Hz .
DISCUSSION:
EXPERIMENT 13
AIM: To generate amplitude modulated signal for specific modulation index and plot the
spectrum.
Theory:
Amplitude modulation (AM) is a one of the conventional technique used to transmit message
signals using a carrier wave. The amplitude or strength of the high frequency carrier wave is
modified in accordance with amplitude of the message signal.
First of all lets get into the basics..
• Carrier signal (Sc) = Acsin(2πfct)
• Message signal (Sm) = Amsin(2πfmt) # fm must be smaller than fc
s(t)=AmAccos(2πfmt)cos(2πfct)
PROGRAM:
clc ;
clear ;
Fc =500; // c a r r i e r f r e q u e n c y i n kHz
Fm =1; // m e s sag e s i g n a l f r e q u e n c y i n kHz
// a )
USB = Fc + Fm ;
LSB = Fc - Fm ;
disp ( USB ,"USBI ( i n kHZ )=") ;
disp ( LSB ,"LSB ( i n kHz )=") ;
//b )
USB1 = Fc + Fm ;
LSB1 = Fc - Fm ;
disp ( USB1 ,"USB( i n kHz )=") ;
disp ( LSB1 ,"LSB ( i n kHZ )=") ;
Amplitude =[0 0 0 0 0 0 0 0 0 5 10 5 0]; // sam pl e a l u e s
frequency =490:1:502;
plot2d3 ( frequency , Amplitude ) ;
xlabel ("F r e q u e n c y ( i n kHZ )") ;
ylabel ("Ampli tude ( i n V)") ;
OUTPUT:
501.
499.
2.
501.5
498.5
clc ;
clear ;
Vm =3; // am pli t u d e of m e s sag e s i g n a l i n V
Vc =5; // am pli t u d e of c a r r i e r s i g n a l i n V
m = Vm / Vc ; // mo d ula tio n i n d e x
disp ("mo d ula tio n i n d e x") ;
disp (m ,"=") ;
disp ("Upper Si d e ba n d F r e q u e n c y ( i n MHz)") ;
Fm =4; // F r e q u e n c y i n KHz
Fc =5; // F r e q u e n c y i n MHz
disp ( Fc +( Fm *10^( -3) ) ,"=") ;
disp ("Lower Si d e ba n d F r e q u e n c y ( i n MHz)") ;
disp ( Fc -( Fm *10^( -3) ) ,"=") ;
disp ("AMplitude of ea c h Si d e ba n d ( i n V)") ;
disp ( m * Vc /2 ,"=") ;
"mo d ula tio n i n d e x"
0.6
"="
"Upper Si d e ba n d F r e q u e n c y ( i n MHz)"
5.004
"="
"Lower Si d e ba n d F r e q u e n c y ( i n MHz)"
4.996
"="
"AMplitude of ea c h Si d e ba n d ( i n V)"
1.5
"="
RESULT: The modulating signal is modulated by high frequency carrier signal. The
amplitude modulated DSB-SC signal and its concerned spectrum is shown in fig 13.1
DISCUSSION:
1. Define amplitude modulation?
2. Differentiate between amplitude and angle modulated signal
3. What is frequency range of AM and FM signal
EXPERIMENT 14
AIM: To develop program for auto correlation and cross correlation for the given two
sequences: x1 = [1 2 3 4] and x2 = [4 3 2 1]
THEORY:
Auto correlation function is a measure of similarity between a signal & its time delayed
version. It is represented with R(k).
The auto correlation function of x(n) is given by
Cross correlation:
Cross-correlation is a measure of similarity of two series as a function of the displacement of
one relative to the other. This is also known as a sliding dot product or sliding inner-product.
The cross-correlation is similar in nature to the convolution of two functions
ny = nx + mx + my -2;
r = nx : ny ;
Rxy = convol (x , y_fold ) ;
Ryx = convol ( x_fold , y) ;
disp ( Rxy ,'C r o s s C o r r e l a t i o n Rxy [ n ] : =')
count =1;
subplot (2 ,1 ,1)
plot2d3 ('gnn',n , x)
xlabel ('n===>')
ylabel ('Amplitude−−>')
title ('I n p u t S e q u e n c e x [ n ]')
subplot (2 ,1 ,2)
plot2d3 ( 'gnn',r , Rxy )
xlabel ('n===>')
ylabel ('Amplitude−−>')
title ('C r o s s c o r r e l a t i o n S e q u e n c e Rxy [ n ]')
OUTPUT:
n t e r t h e F i r s t i n p u t S e q u e n c e :=[1 2 1 1]
E n t e r t h e s e c o n d i n p u t S e q u e n c e :=[1 1 2 1]
E n t e r t h e l o w e r i n d e x of f i r s t i n p u ts e q u e n c e :=0
E n t e r t h e l o w e r i n d e x of s e c o n d i n p u ts e q u e n c e :=0
1. 4. 6. 6. 5. 2. 1.
clc ;
clear ;
close ;
x = input ('E n t e r t h e i n p u t S e q u e n c e :=') ;
m = length ( x ) ;
lx = input ('E n t e r t h e l o w e r i n d e x of i n p u t s e q u e n c e:=')
hx = lx +m -1;
n = lx :1: hx ;
x_fold = x($ : -1:1) ;
nx = lx + lx ;
nh = nx + m +m -2;
r = nx : nh ;
Rxx = convol (x , x_fold ) ;
disp ( Rxx ,'Auto C o r r e l a t i o n Rxx [ n ] : =')
subplot (2 ,1 ,1)
plot2d3 ('gnn',n , x)
Department of ECE Page 85
Digital Signal Processing Lab
xlabel ('n===>')
ylabel ('Amplitude−−>')
title ('I n p u t S e q u e n c e x [ n ]')
subplot (2 ,1 ,2)
plot2d3 ('gnn',r , Rxx )
xlabel ('n===>')
ylabel ('Amplitude−−>')
title ('Auto c o r r e l a t i o n S e q u e n c e Rxx [ n ]')
OUTPUT:
E n t e r t h e i n p u t S e q u e n c e :=[2 -1 3 4 1]
E n t e r t h e l o w e r i n d e x of i n p u t s e q u e n c e:=2
RESULT:
Input sequence and cross correlated sequence is shown in Fig 14.1 and input sequence and
auto correlated sequence is shown in Fig 14.2
DISCUSSION:
1. Write mathematical formula to find auto correlation?
2. Define auto correlation an cross correlation.
3. What is the difference between Auto correlation and cross correlation?
4. What is the length of the resultant sequence of auto correlation?
5. Give the properties of auto correlation.