xcorr returning a triangular shaped plot

I'm currently trying to find a the time delay between peaks in CO2 concentration and the peaks in intensity gained from and MRI scan. But so far when I use xcorr and plot the results I just get a triangular shaped peak at 0 lag which I know can't be right.
Has anyone any idea what I am doing wrong?
So far my code it pretty simple:
a=load(CO2 file)
b=load(MRI file)
T=a/norm(a)
Y=b/norm(b)
time=92 % There are 92 data point
figure 1
plot(time, T, time, Y)% Just to see what the normalised data looks like on the same graph
C=xcorr(a, b, 20, 'coeff') % Only interested in 20 lags either way
time2=-20:20
plot(time2, C) % Results in a triangular-shaped plot

3 件のコメント

ChristianW
ChristianW 2013 年 3 月 4 日
Can you normalise a and b with T=(a-mean(a))/std(a) and show the plot? Alternatively give us some data.
Marek
Marek 2013 年 3 月 4 日
Ahh no need, normalising the data in the way you described has solved the problem now and I'm getting more reasonable results. Thanks!!
TJ
TJ 2013 年 5 月 24 日
Could you elaborate on what fixed your problem? How did you normalize your data and what did that do?

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

回答 (1 件)

Image Analyst
Image Analyst 2013 年 5 月 24 日

0 投票

Maybe you should use normalized cross correlation, done by normxcorr2() in the Image Processing Toolbox (IPT). IPT functions also work with 1D signals as well as 2D images and sometimes 3 dimensions or more.
Often non-periodic signals will correlate and give a roughly triangular, or mountain-shaped, result so what you're seeing is not uncommon. In fact the correlation of two uniform signals will give a perfect triangle - just consider how the area of overlap changes as two boxes slide past each other.

質問済み:

2013 年 3 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by