Calculate timelag using xcorr.
2 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!