XCORR: How to find the location of the highest correlation on the actual data using XCORR
Mostra commenti meno recenti
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
Risposte (2)
Honglei Chen
il 8 Mag 2015
If you just need the highest peak location, you can simply use max
[~,idx] = max(y1)
HTH
3 Commenti
martijn
il 8 Mag 2015
Honglei Chen
il 8 Mag 2015
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
il 8 Mag 2015
Categorie
Scopri di più su Correlation and Convolution in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!