I'm trying to understand how the cross correlation in matlab, mainly xcorr, works. This an example code:
t = -4*pi:0.1:4*pi;
y1 = sin(t*pi);
y2 = sin(t*pi - 0.7*pi);
[acor,lag] = xcorr(y1,y2,50);
[~,I] = max(abs(acor));
lagDiff = lag(I)
and the answer is:
3
Now you multiply the the delta t by 3 so you get (0.1*3) and the time lag is 0.3, while the true answer is 0.7*3.14 which is roughly 2.2 I cant figure out what I'm doing wrong
thanks in advance
t = -4*pi:0.1:4*pi;
? And then you multiplying bypi
again. – Lokesh A. R.