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