Calculate timelag using xcorr.

2 次查看(过去 30 天)
Kolleggerm1
Kolleggerm1 2020-7-2
编辑: dpb 2020-7-2
Hello All,
I am attempting to use the xcorr function to calculate the timelag between two curves (Zrstore and RESIDUALALL(i,:) ) for each i value.
So far I have
for i=w:1:e
[c,lags]=xcorr(Zrstore,RESIDUALALL(i,:));%calculate correlation and lag index for every i
[~,iLag]=max(find(lags==0):end); %find the lag for the current
iLAG(i)=iLag;%store the lag for each i
tlag=((2*pi*B)*iLAG(i))*dt;%calculate the time lag for current i
timelag=tlag(:);%timelag at that i
TIMELAG(i)=timelag; %save the timelag for current i
TIMELAGALL(:)=TIMELAG; %save the timelag for each i
end
I think I am having an issue with storage because all my iLAG values are the same, when I know they should be different.
Does anyone have any thoughts on this?

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by