1## Copyright (C) 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2005, 2006,
3## Copyright (C) 2009 Jaroslav Hajek
5## This file is part of Octave.
7## Octave is free software; you can redistribute it and/or modify it
8## under the terms of the GNU General Public License as published by
9## the Free Software Foundation; either version 3 of the License, or (at
10## your option) any later version.
12## Octave is distributed in the hope that it will be useful, but
13## WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15## General Public License for more details.
17## You should have received a copy of the GNU General Public License
18## along with Octave; see the file COPYING. If not, see
19## <http://www.gnu.org/licenses/>.
22## @deftypefn {Function File} {} meansq (@var{x})
23## @deftypefnx {Function File} {} meansq (@var{x}, @var{dim})
24## For vector arguments, return the mean square of the values.
25## For matrix arguments, return a row vector containing the mean square
26## of each column. With the optional @var{dim} argument, returns the
27## mean squared of the values along this dimension.
30## Author: KH <Kurt.Hornik@wu-wien.ac.at>
31## Description: Compute mean square
33function y = meansq (x, dim)
35 if (nargin != 1 && nargin != 2)
40 t = find (size (x) != 1);
48 y = sumsq (x, dim) / size (x, dim);