0% found this document useful (0 votes)
77 views2 pages

Auto Correlation:: Programme

This document contains MATLAB code to calculate and analyze the autocorrelation and cross-correlation of signals. For autocorrelation, it calculates the autocorrelation of a input signal, verifies properties like energy, symmetry and maximum value. For cross-correlation, it calculates the cross-correlation of two sample signals and plots the results.

Uploaded by

lokeshwarrvrjc
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)
77 views2 pages

Auto Correlation:: Programme

This document contains MATLAB code to calculate and analyze the autocorrelation and cross-correlation of signals. For autocorrelation, it calculates the autocorrelation of a input signal, verifies properties like energy, symmetry and maximum value. For cross-correlation, it calculates the cross-correlation of two sample signals and plots the results.

Uploaded by

lokeshwarrvrjc
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/ 2

AUTO CORRELATION:

Programme:

clc;clear all;close all;
x=input('Enter x[n]:');
n=0:1:length(x)-1;
subplot(2,1,1);
stem(n,x);
xlabel('Time');ylabel('Amplitude');
title('Input sequence x[n] ');
Rxx=xcorr(x);
nRxx=-length(x)+1:length(x)-1;
subplot(2,1,2);
stem(nRxx,Rxx);
xlabel('Time');ylabel('Amplitude');
title('Autocorrelation of x[n]');

%Verification of properties
center_index=ceil(length(Rxx)/2);
Rxx_0=Rxx(center_index);
E=sum(x.^2);
if Rxx_0==E
disp('Energy (Mean square value) property is verified.');
else
disp('Energy property is not verified.');
end
Rxx_right=Rxx(center_index:length(Rxx));
Rxx_left=Rxx(center_index:-1:1);
if Rxx_right==Rxx_left
disp('Autocorrelation is an even function. Hence symmetry property is
verified.');
else
disp('Autocorrelation is not even.');
end
m=max(Rxx);
if m==Rxx_0
disp('Maximum value of autocorrelation function is at zero.');
else
disp('Maximum value is not at zero.');
end
z=x.*2;
Rzz=xcorr(z)/2;
Rmn=Rxx+Rxx;
if Rzz==Rmn
disp('Linearity property is verified');
else
disp('Linearity property is not verified');
end





CROSS CORRELATION:
Aim:To simulate Cross Correlation of two Signals
Software Used:MATLAB6.5
Maltab Commands Required: xcorr,subplot,stem.
Programme:
clear all
x=[2 4 6 8]
y=[1 2 3 4]
z=xcorr(x,y)
subplot(3,1,1)
stem(x)
Title('Cross Correlation')
subplot(3,1,2)
stem(y)
subplot(3,1,3)
stem(z)

You might also like