]> Creatis software - CreaPhase.git/blob - octave_packages/nan-2.5.5/nanmean.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nan-2.5.5 / nanmean.m
1 function [o] = nanmean(i,DIM)
2 % NANMEAN same as SUM but ignores NaN's. 
3 % NANMEAN is OBSOLETE; use MEAN instead. NANMEAN is included 
4 %    to provide backward compatibility 
5 %
6 % Y = nanmean(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 mean
13 %
14
15 % see also: MEAN, SUMSKIPNAN, NANSUM 
16
17 %       $Id: nanmean.m 8223 2011-04-20 09:16:06Z schloegl $
18 %       Copyright (C) 2009 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,n] = sumskipnan(i,DIM);
38 else
39         [o,n] = sumskipnan(i);
40 end;
41 o=o./n;