Monday, November 21, 2011
0
matlab program for crosscorrelation crosscorrelation using matlab
% CROSS CORRELATION
clear all;
x = input('enter first sequence x=');
h = input('enter second sequence =');
N1=length(x);
N2=length(h);
m=0:N1-1;
k=0:N2-1;
N= max(N1,N2);
x =[x zeros(1,N-N1)];
h =[h zeros(1,N-N2)];
if (N1>N2)
p=x;x=h;h=p; %for swapping since first term should be smaller so swapping smaller with biger one
end
z=x;
for i=1:N-1
for i=N-1:-1:1
x(i+1)=x(i); %rotating
end;
x(1)=0; %assigning zero
z=[z; x]; %concatenating matrices
end;
m=[z]*[h']; %cross-correlation
m=m/N;
disp(z);
disp(h);
disp(m);
stem(m);
title('cross-correlation')
xlabel('time index=');
ylabel('amplitude =');
input
enter first sequence x=[1 2 3 4 ]
enter second sequence =[1 2 3 4 5]
clear all;
x = input('enter first sequence x=');
h = input('enter second sequence =');
N1=length(x);
N2=length(h);
m=0:N1-1;
k=0:N2-1;
N= max(N1,N2);
x =[x zeros(1,N-N1)];
h =[h zeros(1,N-N2)];
if (N1>N2)
p=x;x=h;h=p; %for swapping since first term should be smaller so swapping smaller with biger one
end
z=x;
for i=1:N-1
for i=N-1:-1:1
x(i+1)=x(i); %rotating
end;
x(1)=0; %assigning zero
z=[z; x]; %concatenating matrices
end;
m=[z]*[h']; %cross-correlation
m=m/N;
disp(z);
disp(h);
disp(m);
stem(m);
title('cross-correlation')
xlabel('time index=');
ylabel('amplitude =');
input
enter first sequence x=[1 2 3 4 ]
enter second sequence =[1 2 3 4 5]
output
tags:matlab program for correlation matlab code for cross correlation
This post was written by: noufel n backer
Subscribe to:
Post Comments (Atom)
0 Responses to “matlab program for crosscorrelation crosscorrelation using matlab”
Post a Comment