how to calculate time lag from cross correlation data for 365 days?

4 views (last 30 days)
Dear All,
I am sorry if this question is too basic.
I calculated the Cross-correlation function for 365 days (each day devided into 2 segments). Now I want to calculate the lag time by keeping first as a reference.
I know it is simple if we have two function.
I have max 300 seconds as lag time on each sides (positve and negative) and total number of data poitns are 3001*1 as shown in attached picture.
How can i calculate the lag time for each day?

Accepted Answer

Asvin Kumar
Asvin Kumar on 25 Jun 2021
I'm not a 100% clear on what you're trying to achieve but this sounds like a good use case for xcorr. You can look at the usage with the xcorr(x, y, maxlag) syntax. You can skip the second argument in the call to xcorr to calculate auto-correlation.
If it suits your use case, you can perform a max operation on the output from xcorr to identify the lag which gives the highest correlation value. Here's an example of that in the 2D case although the same principles will apply in the 1D case as well: Align two images using cross-correlation

More Answers (0)

Community Treasure Hunt

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

Start Hunting!