%Cross-correlation of a delayed signal
%Purpose: To provide an example of cross-correlation
%Matthew A Clark

%Create Random Plot Signal
N = 100;
n = 0:N-1;
R1 = randn (1,N);

%Create a Version of the Previous That is Delayed Temporally
R1D=[zeros(1,50),R1(1:N-50)];

%Cross Correlate the Two Signals
Ccor = xcorr (R1,R1D);

clf;

%Plot the Results
subplot (1,3,1);
plot (R1);
title ('Base Signal');
xlabel ('Time');
ylabel ('Amplitude');
subplot (1,3,2);
plot (R1D);
title ('Delayed Signal');
xlabel ('Time');
ylabel ('Amplitude');
subplot (1,3,3);
plot (Ccor);
title ('Cross Correlation');
xlabel ('Time');
ylabel ('Amplitude');

