Calculate Lag from xcorr

4 ビュー (過去 30 日間)
rimbak
rimbak 2022 年 3 月 8 日
回答済み: charan 2025 年 5 月 12 日
Hello ,
i want to calculate a time delay by xcorr , but it returns me a lag of 1s instead of 0.5s real delay
my code :
[similarity , lag] = xcorr(puissance,co2_D);
[~, I]= max(abs(similarity));
c = lag(I)
thanks in advance
  2 件のコメント
Mathieu NOE
Mathieu NOE 2022 年 3 月 8 日
編集済み: Mathieu NOE 2022 年 3 月 8 日
hello
are you sure that the delay is constant over the entire data length ?
you may have to split the data in smaller chuncks and do the xcorr stuff on each buffer to see the trend
Mathieu NOE
Mathieu NOE 2022 年 3 月 16 日
hello
problem solved ?

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

回答 (1 件)

charan
charan 2025 年 5 月 12 日
Hi,
I understand that you are getting a delay of 1 second instead of 0.5 seconds. Here are some things to consider:
The "lags" vector contains the lag indices as a vector. These are integer values and represent the delays in terms of integer number of samples. The extracted value "c" gives the delay in number of samples. To obtain the delay in seconds you have to multiply the obtained lag "c", with the sample time of the signal.
Also, using "xcorr" you can only obtain the coarse delay. The possible delay values are only the multiples of the sample time of the signal. If you want to obtain a delay corresponding to fractional number of samples you need to use a different approach.

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by