XCORR: How to find the location of the highest correlation on the actual data using XCORR
이전 댓글 표시
Hi all,
It is already taking me days to understand the xcorr function and I am not able to get it :(!
Example:
x1=[5 4 2.5 0.5 0 0.5 2.5 4 5 5 5]
x2=[0 0.5 2.5 4 5 5 5]
y1=xcorr(x1,x2)
plot(y1) gives me:

First I thought: GREAT!
But why is the highest correlation on 15, I wrote down 100 of notes to figure it out. All I need is the location on x1 where the correlation is the highest.
In my actual dataset x1 is deoxygenation during exercise (first down during exercise, then mono-exponentially up in recovery). My x2 is a monoexponential shaped curve, in this way I want to find the response time, the point where the data is shaped mono-exponential.
Maybe the answer is easy, which would save me lots of frustrations!
Thanks in advance
답변 (2개)
Honglei Chen
2015년 5월 8일
If you just need the highest peak location, you can simply use max
[~,idx] = max(y1)
HTH
댓글 수: 3
martijn
2015년 5월 8일
Honglei Chen
2015년 5월 8일
I see, I misunderstood. You should use the second output argument in xcorr, such as
[y1, lags] = xcorr(x1,x2);
[~,idx] = max(y1);
lags(idx)
Is this what you want?
martijn
2015년 5월 8일
카테고리
도움말 센터 및 File Exchange에서 Correlation and Convolution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!