interpreting xcorr for time series plots

조회 수: 2 (최근 30일)
CG
CG 2024년 9월 10일
댓글: Jatin 2024년 9월 12일
i'm using xcorr to work out the lag between two time series.
When I plot the results of xcorr, and ask it to return the maximum lag, the result I get is -58.3.
This is the maximum positive c value, but the spike at 0 into negative c values is the largest overall - is this the result i should be using instead?

답변 (1개)

Jatin
Jatin 2024년 9월 10일
편집: Jatin 2024년 9월 10일
Hi @CG,
The result you should choose depends on the context of your analysis. The "xcorr" function represents "the similarity between a vector x and shifted (lagged) copies of a vector y as a function of the lag." If your goal is to find the exact shift needed to align the signals, you should select the highest correlation value, whether it occurs at a positive or negative lag.
Since you mentioned that the spike at lag 0 is the largest, this indicates the signals are best aligned without any shift. Therefore, if you're looking for the best overall alignment, you can use the lag at 0.
Refer the below documentation on "xcorr" for more details on how the function works:
Hope this helps!
  댓글 수: 2
CG
CG 2024년 9월 10일
Thanks for replying.
I got confused with the documentation as the examples only show postive correlation values, whereas my plots show positive and negative.
I am looking for the best overall alignment, so therefore I should choose the largest spike in the plot, whether that occurs at a positive or negative correlation value.
Thanks
Jatin
Jatin 2024년 9월 12일
Glad that it was helpful.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by