0% found this document useful (0 votes)
10 views5 pages

Untitled Document

The document outlines an experiment to write a MATLAB program for obtaining Auto Correlation and Cross Correlation of two sequences. It includes the theory behind cross-correlation, an algorithm for implementation, and sample MATLAB code with expected outputs. The result confirms the successful execution of the program to analyze the correlation between the input sequences.

Uploaded by

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

Untitled Document

The document outlines an experiment to write a MATLAB program for obtaining Auto Correlation and Cross Correlation of two sequences. It includes the theory behind cross-correlation, an algorithm for implementation, and sample MATLAB code with expected outputs. The result confirms the successful execution of the program to analyze the correlation between the input sequences.

Uploaded by

aksheenjane03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

LOYOLA - ICAM

COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)

Ex.No -3
Auto Correlation and Cross Correlation
Date:

AIM:
To write a MATLAB program to obtain the Auto Correlation and Cross Correlation of
two sequences.

APPARATUS REQUIRED:
MATLAB, PC

THEORY:

In signal processing, cross-correlation is a measure of similarity of two series as a function


of the lag of one relative to the other. This is also known as a sliding Dot product orsliding
inner-product. It is commonly used for searching a long signal for a shorter, known feature. It
has applications in Pattern Recognition, Single Particle Analysis, Electron Tomography,
Averaging, Cryptanalysis and Neurophysiology,

For continuous functions f and g, the cross-correlation is defined as:

where denotes the Complex Conjugate of and is the lag.


Similarly, for discrete functions, the cross-correlation is defined as:

The cross-correlation is similar in nature to the convolution of two functions.

In Autocorrelation, which is the cross-correlation of a signal with itself, there will always be
a peak at a lag of zero, and its size will be the signal power.
LOYOLA - ICAM
COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)

ALGORITHM:
1.​ Give the input sequences
2.​ Use the inbuilt MATLAB function (XCORR) to find out the correlation
3.​ Plot the output graph
4.​ Observe the result in the command window

PROGRAM:

AUTO CORRELATION

x=input('Enter first sequence:');


h=input('Enter second sequence:');
n= length(x);
n1=0:n-1;
t= length(h);
n2=0:t-1;
y= xcorr(x,h);
disp(y);
subplot(3,1,1);
stem(n1,x);
title('Input 1');
xlabel('Time');
ylabel('Amplitude');
subplot(3,1,2);
stem(n2,h);
title('Input 2');
xlabel('Time');
ylabel('Amplitude');
subplot(3,1,3);
stem(y);
title('Cross Correlation');
xlabel('Time');
ylabel('Amplitude');
OUTPUT:

Enter first sequence:[1,2,3,4]

Enter second sequence:[7,9,8]

-0.0000 8.0000 25.0000 49.0000 73.0000 57.0000 28.0000

GRAPH:
LOYOLA - ICAM
COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)

CROSS CORRELATION:

a = input('Enter the input signal: ');


subplot(2,1,1);
stem(a);
title('Input Signal');
xlabel('Time');
ylabel('Amplitude');
b = xcorr(a);
subplot(2,1,2);
stem(b);
title('Autocorrelation of the Input Signal');
xlabel('Lag');
ylabel('Amplitude');

OUTPUT:

Enter the input signal : [1,2,3,4]

4.0000 11.0000 20.0000 30.0000 20.0000 11.0000 4.0000

GRAPH:
LOYOLA - ICAM
COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)

Preparation 5
Conduction &
Observation 5
Result Execution
Viva-Voce &
5
Inference
Record 5
Total 20

RESULT:
​ Thus a MATLAB program is written to obtain the Auto Correlation and Cross
Correlation of two sequences

You might also like