Code to calculate a cross correlation function for many scales

I would like to calculate a cross correlation function on many scales, in the file attached chapter 2 Multiscale correlation function. I don't know if the code here is the right one, i have some small differences with results in the paper. >> X=cumsum(x); %%integrate and set profile series
>> Y=cumsum(y);
>> X=transpose(X);
>> Y=transpose(Y);
>> N=length(X);
for n=3:150,
for i=1:N-n,
ind1=i;
ind2=i+n;
index=(ind1:ind2);
C0=polyfit(index, X(index),1);
C1=polyfit(index,Y(index),1);
fit0=polyval(C0,index);
fit1=polyval(C1,index);
Cov{n}(i)=(1/(n-1))*sum((X(index)-fit0).*(Y(index)-fit1));
CovX{n}(i)=(1/(n-1))*sum((X(index)-fit0).*(X(index)-fit0));
CovY{n}(i)=(1/(n-1))*sum((Y(index)-fit1).*(Y(index)-fit1));
end
CovXY(n)=(1/(N-n))*sum(Cov{n});
VarX (n)=(1/(N-n))*sum(CovX{n});
VarY (n)=(1/(N-n))*sum(CovY{n});
end
for j=1:150
rho (j)=CovXY(j)/sqrt(VarX(j).*VarY(j));
end

回答(1 个)

this is the paper of reference, look at paragraph 2 Multiscale cross correlation

类别

帮助中心File Exchange 中查找有关 Time Series 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by