06-05-2011, 03:35 PM
Procedure:-
1. Read the input sequence
2. Autocorrelate the signal using xcorr(x,x)
3. Display the Autocorrelation result in suitable axis
4. verify the correlation property:Rxx(0)=energy(x)
5. verify the property :Rxx is an even function
MATLAB program for autocorrelation
Code:
clear
clc
close all
% READ THE INPUT SIGNAL
x = [1 2 1 1];
%Define the axis
n = 0:1:length(x)-1;
% PLOT THE SIGNAL
subplot(2,1,1);
stem(n,x);
xlabel('n--->');
ylabel('x--->');
title('sequence x');
grid on;
% AUTOCORRELATE THE SIGNAL
Rxx = xcorr(x)
% AXIS FOR THE AUTOCORRELATION RESULT
nRxx = -length(x)+1:length(x)-1
% Display the result
subplot(2,1,2);
stem(nRxx,Rxx);
xlabel('nRxx--->');
ylabel('autocorrelation of x--->');
title('Autocorrelated sequence of x');
grid on;
%% VERIFICATION OF THE AUTOCORRELATION PROPERTIES
% PROPERTY-1: RXX(0) GIVES THE ENERGY OF THE SIGNAL
% Energy OF THE SIGNAL = SUM(SQUARES OF X)
Energy = sum(x.^2);
% GET THE INDEX OF THE CENTER VALUE
center_index = ceil(length(Rxx)/2)
% ACCESS CENTER VALUE RXX(0)
Rxx_0 = Rxx(center_index)
% CHECK IF THE RXX(0) = ENERGY
if (Rxx_0 == energy)
disp('Rxx(0) gives energy -- propert-1 is proved');
else
disp('Rxx(0) gives energy -- propert-1 is not proved');
end
% PROPERTY-2: RXX IS EVEN
Rxx_Right = Rxx(center_index:1:length(Rxx));
Rxx_Left = Rxx(center_index:-1:1);
if Rxx_Right == Rxx_Left
disp('Rxx is even');
else
disp('Rxx is not even');
end
RESULT:- AUTOCORRELATION