Calculating the time delay between the two pulses illustrated here, using the function finddelay(pulse1,pulse2), I get the correct value of 8.73 nsec. However when I use xcorr(pulse1,pulse2), the result is about 11.2 nsec... What am I doing wrong here?
xcorr:
r=xcorr(pulse1,pulse2);
[a,b]=max(r);
delay=20/4096*b;
here's the plot for the cross correlation
finddelay:
delay=finddelay(v1,v2);
t=20/4096*delay;
In the first case delay=2308 and in the second one delay=1788
In your question you haven't mentioned sampling frequency since the
finddelayandxcorrwill give you the delay in number of samples.Check this example,
Where the answer for both
d1andd2is1.