Experiment: Auto Correlation and Cross Correlation: y (T) X (T) H (T)

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

Experiment: Auto correlation and Cross correlation

Aim: To compute Auto correlation and Cross correlation between signals and
sequences.
Software Required: Mat lab software
Theory:

Difference between convolution and correlation


Theoretically, convolution is linear operations on the signal or signal
modifiers, whereas correlation is a measure of similarity between two
signals.
Convolution

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

Correlation
Correlation is a measure of similarity between two signals. The general
formula for correlation is

There are two types of correlation:


 Auto correlation
 Cross correlation
Auto Correlation Function

It is defined as correlation of a signal with itself. Auto correlation function is


a measure of similarity between a signal & its time delayed version.

Cross Correlation Function

Cross correlation is the measure of similarity between two different signals.

Correlations of sequences:
It is a measure of the degree to which two sequences are similar. Given two
real-valued sequences x(n) and y(n) of finite energy,
Convolution involves the following operations.
1. Shifting
2. Multiplication
3. Addition
These operations can be represented by a Mathematical Expression as
follows:

The index l is called the shift or lag parameter


Program Code:
clc;
close all;
clear all;
% two input sequences
x=input('enter input sequence');
h=input('enter the impulse sequence');
subplot(2,2,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input sequence');
subplot(2,2,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('impulse sequence');
% cross correlation between two sequences
y=xcorr(x,h);
subplot(2,2,3);
stem(y);
xlabel('n');
ylabel('y(n)');
title(' cross correlation between two sequences ');
% auto correlation of input sequence
z=xcorr(x,x);
subplot(2,2,4);
stem(z);
xlabel('n');
ylabel('z(n)');
title('auto correlation of input sequence');
% cross correlation between two signals
% generating two input signals
t=0:0.2:10;
x1=3*exp(-2*t);
h1=exp(t);
figure;
subplot(2,2,1);
plot(t,x1);
xlabel('t');
ylabel('x1(t)');
title('input signal');
subplot(2,2,2);
plot(t,h1);
xlabel('t');
ylabel('h1(t)');
title('impulse signal');
% cross correlation
subplot(2,2,3);
z1=xcorr(x1,h1);
plot(z1);
xlabel('t');
ylabel('z1(t)');
title('cross correlation ');
% auto correlation
subplot(2,2,4);
z2=xcorr(x1,x1);
plot(z2);
xlabel('t');
ylabel('z2(t)');
title('auto correlation ');

Result: Auto correlation and Cross correlation between signals and


sequences is computed.
Output: enter input sequence [1 2 5 7]
enter the impulse sequence [2 6 0 5 3]

You might also like