I am new to this forum. I am just trying to understand how to calculate delay (in terms of samples) between two signals using cross-correlation function. I wrote a small Matlab code in order to understand this. But I am finding difficulty in understanding the results.
clc;
fm = 1000; //message signal
fs = 10 * fm; //sampling frequency
ts = 1 /fs;
t = 0:ts:1-ts;
x=sin(2*pi*fm*t);
y=cos(2*pi*fm*t);
[r,s] = xcorr(x,y);
subplot(2,1,1);
plot(r);
subplot(2,1,2);
plot(s);
The results obtained using this code are as follows.
From the figure, we can observe that the peak is occurring at around 10,000 sample. So, can 10,000 samples be considered as a delay (in samples) between two signals? And does the corresponding time delay is 10000 * 1/10000 = 1 sec in this case?