Technical discussions related to Audio Signal Processing (digital effects, acoustics, noise reduction, musical signal processing, etc).
Post a new Thread
cross correlation and time delay - onth...@gmail.com - Feb 16 15:03:00 2006
hi all,
i have been trying to get a program that can give me the time delay of 2 sine signals..
clear all
f=100
t=[0:0.001:0.05]
A1=sin(f*2*pi*t)
timedelay=0.02
A2=sin(f*2*pi*(t+timedelay))
xc=xcorr(A1,A2);
[a,delay]=max(xc)
figure
subplot(311),plot(A1)
subplot(312),plot(A2)
subplot(313),plot(xc)
this program, given to me by a friend, does not seem to work correctly.. the peak on the graph
should denote the time delay (0.02), instead, it peaks at 0.05...
can anyone please help me with this and tell me where i am going wrong?
thanks a million
regards,
nikhil

(You need to be a member of audiodsp -- send a blank email to audiodsp-subscribe@yahoogroups.com )
Re: cross correlation and time delay - Martin Eisenberg - Feb 17 17:38:00 2006
From: <onthelimit@onth...>
> i have been trying to get a program that can
> give me the time delay of 2 sine signals..
If my reply to your private query was unsatisfactory you should
have said so.
Martin

(You need to be a member of audiodsp -- send a blank email to audiodsp-subscribe@yahoogroups.com )
Re: cross correlation and time delay - Harish Kumar - Feb 19 16:27:00 2006
Hi there,
Here is the deal. The xcorr function in matlab returns a vector which is actually
c(m) =
Cxy(m-N)
which is actually of length 2*N -1, N being the length of the input vectors.
therefore, when you take crosscorrelation of two identical signals, the peak will be at
c(N). In the above case, with a delay of 0.02 and f = 100, it's a shift of 100*0.02*pi*2 =
4*pi. which means there is no actual shift in the shape of the sine two sine waves. That is why
you get a peak at 0.05.

(You need to be a member of audiodsp -- send a blank email to audiodsp-subscribe@yahoogroups.com )