Azzera filtri
Azzera filtri

time delay between two signals from the same source

4 visualizzazioni (ultimi 30 giorni)
Hi
Could someone help me to find the time delay between two signals coming from the same source by using the concepts of correlation and autocorrelation. I am new to matlab, so could you please explain from the basic concepts?
Thanks in advance

Risposta accettata

Honglei Chen
Honglei Chen il 27 Ott 2011
You can use xcorr to determine the delay in samples and then use sampling frequency to find out the exact delay in time.
fs = 100;
t = 0:1/fs:1;
x = sin(2*pi*t);
y = sin(2*pi*t+pi/10);
[c, lags] = xcorr(x,y)
If you examine c, the maximum is at index 106, which corresponds t a lag of (see lags) 5. This means the two signals match at a delay of 5 samples. You can translate that to time by dividing the number of samples with the sampling frequency. You can also use findpeaks to automate the peak search.
HTH

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by