### changeset 12077:f3e70f64c30crelease-3-2-x

std.m: correctly work along singleton dimension
author John W. Eaton Tue, 01 Sep 2009 09:26:33 +0200 279d2f4102d7 48a9c78cfbc9 scripts/ChangeLog scripts/statistics/base/std.m 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
```--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@
+2009-08-06  John W. Eaton  <jwe@octave.org>
+
+	* statistics/base/std.m: Correctly work along singleton dimension.
+	From Christoph Ellenberger <C.Ellenberger@gmx.net>.
+
2009-08-06  Olaf Till <olaf.till@uni-jena.de>

* geometry/griddata.m: Linearize arrays.```
```--- a/scripts/statistics/base/std.m
+++ b/scripts/statistics/base/std.m
@@ -64,7 +64,7 @@
if (nargin < 1 || nargin > 3)
print_usage ();
endif
-  if nargin < 3
+  if (nargin < 3)
dim = find (size (a) > 1, 1);
if (isempty (dim))
dim = 1;
@@ -76,7 +76,7 @@

n = size (a, dim);
if (n == 1)
-    retval = zeros (sz);
+    retval = zeros (size (a));
elseif (numel (a) > 0)
retval = sqrt (sumsq (center (a, dim), dim) / (n + opt - 1));
else
@@ -89,8 +89,9 @@
%! x = ones (10, 2);
%! y = [1, 3];
%! assert(std (x) == [0, 0] && abs (std (y) - sqrt (2)) < sqrt (eps));
+%! assert (std (x, 0, 3), zeros (10, 2))
+%! assert (std (ones (3, 1, 2), 0, 2), zeros (3, 1, 2))

%!error std ();

%!error std (1, 2, 3, 4);
-```