Documentation of dof_corr


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


Function Synopsis

dof = dof_corr(y, x);

Help text


  dof = dof_corr(y, x);

  Where x is a time-series, and y is the data field


Cross-Reference Information

This function calls This function is called by

Listing of function dof_corr

function dof = dof_corr(y, x);

lim = 0.001;

szy = size(y);
ndim = length(szy);
y = reshape(y, szy(1), prod(szy(2:ndim)));

[ntimx, nptx] = size(x);
if ntimx == 1; x = x'; [ntimx, nptx] = size(x); rotx = 1; end;
[ntimy, npty] = size(y);
if ntimy == 1; y = y'; [ntimy, npty] = size(y); roty = 1; end;

if (ntimy <= 5 | ntimx <= 5);
  error('Must have at least 5 elements');
end

if ntimx ~= ntimy;
  error('Either y is oriented incorrectly, or x and y are not the same length');
end

denom = ones(1, npty);
kp2 = 1:npty;
keep_going = 1;
i = 1;

while(keep_going);
  
  ccx = corr2(x, x, i);
  ccy = corr2(y(:,kp2), y(:,kp2), i);

  kp = find(ccy >= lim);

  if (~isempty(kp) & ccx >= lim);
    kp2 = kp2(kp);
    denom(kp2) = denom(kp2) + 2*(1 - (i/ntimy)) * ccx * ccy(kp);
    i = i + 1;
  else
    keep_going = 0;
  end
end

dof = ntimy ./ denom;

if length(szy)>2; dof = reshape(dof, szy(2:ndim)); end