You are on page 1of 1

% CROSS-CORRELATION

clc;
clear all;
close all;
x=input('enter the first seq');
h=input('Enter the impulse response');
h1=fliplr(h);
l1=length(x);
l2=length(h1);
L=l1+l2-1;;
x=[x zeros(1,L-l1)];
h1=[h1 zeros(1,L-l2)];
for n=1:L
y(n)=0;
for i=1:L
j=n-i+1;
if(j<=0)
j=j+L;
end
y(n)=y(n)+x(i)*h1(j);
end
end
disp('the output seq is');y
n=0:L-1;
stem(n,y);
xlabel('Time-->');
ylabel('Amplitude');
title('Cross-Correlation');
grid

You might also like