Cross Correlation to determine Delay

Hi,
I have 2 signals of equal length. The signals correlate but with a time delay. I thought of doing a cross-correlation between both signals to determine the lag at which both signals have the maximum correlation. I've written the following line of code to do that.
[c,lags]=xcorr(signal1,signal2,20);
Plotting both signals and their cross-correlation returns this.
I was expecting to see a peak at approx. positive or negative 10 because that's when both signals drop significantly. I can't seem to figure out why that isn't the case. Is it because both signals have the same length?
Any help would be very much appreciated!

3 件のコメント

Tim
Tim 2023 年 6 月 2 日
Both of the signals have a large bias; your cross correlation values are going to predominantly be affected by this bias, not signal variation. Try making the signals zero-mean before cross-correlating.
Samuel
Samuel 2023 年 6 月 2 日
Can I achieve that by subtracting the mean from my signals?
Tim
Tim 2023 年 6 月 2 日
yes

サインインしてコメントする。

回答 (0 件)

製品

リリース

R2021b

質問済み:

2023 年 6 月 2 日

コメント済み:

Tim
2023 年 6 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by