diff --git a/scripts/statistics/base/mean.m b/scripts/statistics/base/mean.m --- a/scripts/statistics/base/mean.m +++ b/scripts/statistics/base/mean.m @@ -102,13 +102,12 @@ ## Find the first non-singleton dimension. (dim = find (sz > 1, 1)) || (dim = 1); else - if (!(isscalar (dim) && dim == fix (dim)) - || !(1 <= dim && dim <= nd)) + if (! (isscalar (dim) && dim == fix (dim) && dim > 0)) error ("mean: DIM must be an integer and a valid dimension"); endif endif - n = sz(dim); + n = size (x, dim); if (strcmp (opt, "a")) y = sum (x, dim) / n;