hello everyone,

I have two vectors and I want to test their correlation at multiple leads/lags. One of the vectors is continuous, the other patched with NaN values/ gaps. I use MATLAB and the correlation functions in there (xcorr and corrcoeff) mess up with NaNs. If I cut out all the years (from both vectors), where there are NaNs in vector 2, it works but now the frequency of my timeseries has changed, no? I believe, however, that it is important for me to preserve this as I am assessing El Nino cycles. Can I set all the NaNs to 0? Or will that mess up the correlation results?

On that note: one of the issues that confuses me a bit is that with "clean" timeseries xcorr and corrcoeff should give me the same results for a zero lag (when setting 'coeff' for xcorr), but this is not the case. Am I misinterpreting the way these functions work?

Thanks in advance