Calculate timelag using xcorr.

1 view (last 30 days)
Kolleggerm1
Kolleggerm1 on 2 Jul 2020
Edited: dpb on 2 Jul 2020
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?

Answers (0)

Community Treasure Hunt

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

Start Hunting!