]> Creatis software - CreaPhase.git/blob - octave_packages/nan-2.5.5/nansum.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nan-2.5.5 / nansum.m
1 function [o] = nansum(i,DIM)
2 % NANSUM same as SUM but ignores NaN's. 
3 % NANSUM is OBSOLETE; use SUMSKIPNAN instead. NANSUM is included 
4 %    to fix a bug in some other versions. 
5 %
6 % Y = nansum(x [,DIM])
7
8 % DIM   dimension
9 %       1 sum of columns
10 %       2 sum of rows
11 %       default or []: first DIMENSION with more than 1 element
12 % Y     resulting sum
13 %
14
15 % see also: SUM, SUMSKIPNAN, NANSUM 
16
17 %       $Id: nansum.m 9033 2011-11-08 20:58:07Z schloegl $
18 %       Copyright (C) 2000-2003,2008 by Alois Schloegl <alois.schloegl@gmail.com>       
19 %       This is part of the NaN-toolbox. For more details see
20 %       http://pub.ist.ac.at/~schloegl/matlab/NaN/
21 %
22 %    This program is free software; you can redistribute it and/or modify
23 %    it under the terms of the GNU General Public License as published by
24 %    the Free Software Foundation; either version 3 of the License, or
25 %    (at your option) any later version.
26 %
27 %    This program is distributed in the hope that it will be useful,
28 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
29 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30 %    GNU General Public License for more details.
31 %
32 %    You should have received a copy of the GNU General Public License
33 %    along with this program; If not, see <http://www.gnu.org/licenses/>.
34
35
36 if nargin>1
37         o = sumskipnan(i,DIM);
38 else
39         o = sumskipnan(i);
40 end;
41
42 %!assert(nansum(NaN),0)
43