Documentation of filter_nr


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


Function Synopsis

dout = filter_nr(vect, data);

Help text


  dout = filter_nr(weights, data);
 
  Non-recursive filtering using centered weights

  Inputs: 
  weights are the non-recursive weights (e.g., [1 2 1]/4)
  data will be smoothed in the column dimension

  Outputs:
  dout is the filtered output data.  If the length of weights
       is odd, then there will be no phase shift.  But, the
       first (length(weights)-1)/2 points are affected by the
       endpoints.


Listing of function filter_nr

function dout = filter_nr(vect, data);
if ndims(data) > 2;
  reshape_data = 1;
  sz_dat = size(data);
  data = reshape(data, sz_dat(1), prod(sz_dat(2:end)));
else
  reshape_data = 0;
end

lvect = length(vect);
if ~mod(lvect,2);
  error('This will introduce a phase shift.  Please use odd number of weights');
end
vect = vect/sum(vect);

[ntim, nx] = size(data);
kp = ((length(vect)-1)/2)+[1:ntim];
dout = repmat(NaN, [ntim nx]);

for i = 1:nx;
  tem = conv(vect, data(:,i));
  dout(:,i) = tem(kp);
end

if reshape_data;
  dout = reshape(dout, sz_dat);
end