Documentation of autocorr

Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)

Function Synopsis

a = autocorr(x, lags);

Help text

  a = autocorr(x, lags);

  x is the input data vector
  lags is 0:(length(x)-2), unless otherwise specified

Listing of function autocorr

function a = autocorr(x, lags);

if ~all([length(size(x))==2 , ismember(1, size(x))]); 
  error('x must be a vector');

if nargin == 1;
  lags = 0:(length(x)-2);

nlag = length(lags);
ntim = length(x);
a = repmat(NaN, [nlag 1]);

for i = 1:nlag;
  ind1 = 1:(ntim-abs(lags(i)));
  ind2 = (1+abs(lags(i))):ntim;
  tem = corrcoef(x(ind1), x(ind2));
  a(i) = tem(1,2);