]> Creatis software - CreaPhase.git/blob - octave_packages/nan-2.5.5/meansq.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nan-2.5.5 / meansq.m
1 function o=meansq(x,DIM,W)
2 % MEANSQ calculates the mean of the squares
3 %
4 % y = meansq(x,DIM,W)
5 %
6 % DIM   dimension
7 %       1 STD of columns
8 %       2 STD of rows
9 %       N STD of  N-th dimension 
10 %       default or []: first DIMENSION, with more than 1 element
11 % W     weights to compute weighted mean (default: [])
12 %       if W=[], all weights are 1. 
13 %       number of elements in W must match size(x,DIM) 
14 %
15 % features:
16 % - can deal with NaN's (missing values)
17 % - weighting of data  
18 % - dimension argument also in Octave
19 % - compatible to Matlab and Octave
20 %
21 % see also: SUMSQ, SUMSKIPNAN, MEAN, VAR, STD, RMS
22
23 %    This program is free software; you can redistribute it and/or modify
24 %    it under the terms of the GNU General Public License as published by
25 %    the Free Software Foundation; either version 2 of the License, or
26 %    (at your option) any later version.
27 %
28 %    This program is distributed in the hope that it will be useful,
29 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
30 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31 %    GNU General Public License for more details.
32 %
33 %    You should have received a copy of the GNU General Public License
34 %    along with this program; If not, see <http://www.gnu.org/licenses/>.
35
36 %       Copyright (C) 2000-2003,2009 by Alois Schloegl <alois.schloegl@gmail.com>       
37 %       $Id: meansq.m 8223 2011-04-20 09:16:06Z schloegl $
38 %       This function is part of the NaN-toolbox for Octave and Matlab 
39 %       http://pub.ist.ac.at/~schloegl/matlab/NaN/
40
41
42 if nargin<3,
43         W = [];
44 end;    
45 if nargin<2,
46         [o,N,ssq] = sumskipnan(x,[],W);
47 else
48         [o,N,ssq] = sumskipnan(x,DIM,W);
49 end;
50
51 o = ssq./N;
52
53