Pages

Friday, 22 February 2013

Cross Correlation Using Function (Matlab 2012a)

Program:

clc;
clear all;
x1 = input('Enter the first sequence = ');
x2 = input('Enter the second sequence = ');
y = xcorr(x1,x2);
subplot(3,1,1);
stem(x1);
title('First Sequence');
ylabel('Amplitude---->');
xlabel('n---->');
grid on;
subplot(3,1,2);
stem(x2);
title('Second Sequence');
ylabel('Amplitude---->');
xlabel('n---->');
grid on;
subplot(3,1,3);
stem(x2);
title('Cross Correlation Sequence');
ylabel('Amplitude---->');
xlabel('n---->');
grid on;
disp('Cross Correlation Sequence = ');
disp(y);


Output:

Enter the first sequence = [1 2 3 4]
Enter the second sequence = [4 3 2 1]
Cross Correlation Sequence =
    1.0000    4.0000   10.0000   20.0000   25.0000   24.0000   16.0000


Waveform:

 

No comments:

Post a Comment