Sie sind auf Seite 1von 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)

Das könnte Ihnen auch gefallen