Documentation of sum4vms


Global Index (short | long) | Local contents | Local Index (short | long)


Function Synopsis

y=sum4vms(x)

Help text

SUM    Sum of the elements.
   For vectors, SUM(X) is the sum of the elements of X.
   For matrices, SUM(X) is a row vector with the sum over
   each column. SUM(DIAG(X)) is the trace of X.

   See also PROD, CUMPROD, CUMSUM.

Cross-Reference Information

This function is called by

Listing of function sum4vms

function y=sum4vms(x)

%   L. Ljung
%   Copyright (c) 1986-98 by The MathWorks, Inc.
%   $Revision: 2.3 $  $Date: 1997/12/02 03:44:23 $

if isempty(find(isnan(x)))
  %regular sum
  y=sum(x);
else
  [t1,t2]=size(x);
  if min(t1,t2) == 1
    y=NaN;
  else
    for i=1:t2
      if isempty(find(isnan(x(:,i))))
        y(i) = sum(x(:,i));
      else
        y(i) = NaN;
      end;
    end;
  end;
end;