locdetrend

PURPOSE ^

Remove running line fit (using local linear regression)-continuous

SYNOPSIS ^

function data=locdetrend(data,Fs,movingwin)

DESCRIPTION ^

  Remove running line fit (using local linear regression)-continuous
  processes
  Usage: data=locdetrend(data,Fs,movingwin)
  Inputs:
 Note that units of Fs, movinwin have to be consistent.
  data         (data as a matrix times x channels or a single vector) 
  Fs           (sampling frequency) - optional. Default 1
  movingwin    (length of moving window, and stepsize) [window winstep] - optional.
                   Default. window=full length of data (global detrend).
                   winstep=window -- global detrend
 
 Output:
 data:         (locally detrended data)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function data=locdetrend(data,Fs,movingwin)
0002 %  Remove running line fit (using local linear regression)-continuous
0003 %  processes
0004 %  Usage: data=locdetrend(data,Fs,movingwin)
0005 %  Inputs:
0006 % Note that units of Fs, movinwin have to be consistent.
0007 %  data         (data as a matrix times x channels or a single vector)
0008 %  Fs           (sampling frequency) - optional. Default 1
0009 %  movingwin    (length of moving window, and stepsize) [window winstep] - optional.
0010 %                   Default. window=full length of data (global detrend).
0011 %                   winstep=window -- global detrend
0012 %
0013 % Output:
0014 % data:         (locally detrended data)
0015 data=change_row_to_column(data);
0016 [N,C]=size(data);
0017 if nargin < 2; Fs=1; end;
0018 if nargin < 3; movingwin=[N/Fs N/Fs]; end; 
0019 Tw=movingwin(1); Ts=movingwin(2);
0020 
0021 n=round(Fs*Tw);
0022 dn=round(Fs*Ts);
0023 if ~isreal(data) 
0024   yr=real(data); 
0025   yi=imag(data); 
0026   for ch=1:C
0027       tmp=runline(yr(:,ch),n,dn); 
0028       yr=yr-tmp;
0029       tmp=runline(yi(:,ch),n,dn); 
0030       yi=yi-tmp;
0031       tsr(:,ch)=yr+i*yi;
0032   end;
0033 else
0034   for ch=1:C;
0035       tmp=runline(data(:,ch),n,dn); 
0036       data(:,ch)=data(:,ch)-tmp;
0037   end;
0038 end

Generated on Tue 28-Mar-2006 14:37:41 by m2html © 2003