Documentation of rsum


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


Function Synopsis

[y, nsum] = rsum ( x, n, usenan ) ;

Help text

 function [y, nsum] = rsum ( x, n, usenan ) ;

  x = input matrix or vector
  n = number of points used in averaging, default is 5;
      when n < 0; cyclic boundary conditions are assumed
      otherwise, first and last values are repeated in averaging
      nsum = number of elements in each sum
-------------------------------------- Alexis Lau (Feb 1992)
  usenan = when set to true, missing boundary values are replaced
      by NaNs.
-------------------------------------- Alexis Lau (Feb 1993)

Cross-Reference Information

This function calls

Listing of function rsum

function [y, nsum] = rsum ( x, n, usenan ) ;
nd = ndims(x);
nsz = size(x);
x = reshape(x, nsz(1), prod(nsz(2:nd)));

if nargin == 3;
  [y, nsum] = myrunning_sum( x, n, usenan ) ;
elseif nargin == 2;
  [y, nsum] = myrunning_sum( x, n ) ;
elseif nargin == 1;
  [y, nsum] = myrunning_sum( x ) ;
else
  error(['Look at what you''re doing, dummy.'])
end

y = reshape(y, nsz);
nsum = reshape(nsum, nsz);