Calculates autocorrelations for multiple data series. Missing values in Z (NaN) are considered. Also calculates Ljung-Box Q stats and p-values. [AutoCorr,stderr,lpq,qpval] = acorf(Z,N); If mean should be removed use [AutoCorr,stderr,lpq,qpval] = acorf(detrend(Z',0)',N); If trend should be removed use [AutoCorr,stderr,lpq,qpval] = acorf(detrend(Z')',N); INPUT Z is data series for which autocorrelations are required each in a row N maximum lag OUTPUT AutoCorr nr x N matrix of autocorrelations stderr nr x N matrix of (approx) std errors lpq nr x M matrix of Ljung-Box Q stats qpval nr x N matrix of p-values on Q stats All input and output parameters are organized in rows, one row corresponds to one series REFERENCES: S. Haykin 'Adaptive Filter Theory' 3ed. Prentice Hall, 1996. M.B. Priestley 'Spectral Analysis and Time Series' Academic Press, 1981. W.S. Wei 'Time Series Analysis' Addison Wesley, 1990. J.S. Bendat and A.G.Persol 'Random Data: Analysis and Measurement procedures', Wiley, 1986.