Mercurial > octave-nkf
diff scripts/statistics/base/moment.m @ 5568:e9cde940b271
[project @ 2005-12-08 02:28:22 by jwe]
author | jwe |
---|---|
date | Thu, 08 Dec 2005 02:28:22 +0000 |
parents | ec8c33dcd1bf |
children | 34f96dd5441b |
line wrap: on
line diff
--- a/scripts/statistics/base/moment.m Wed Dec 07 06:31:28 2005 +0000 +++ b/scripts/statistics/base/moment.m Thu Dec 08 02:28:22 2005 +0000 @@ -75,7 +75,7 @@ usage ("moment: expecting opt to be a string"); endif else - usage ("moment (x, p, dim, opt) or moment (x, p, dim, opt)"); + usage ("moment (x, p, dim, opt)"); endif if (need_dim) @@ -94,21 +94,15 @@ error ("moment: x must not be empty"); endif - tmp = warn_str_to_num; - unwind_protect - warn_str_to_num = 0; - if any (opt == "c") - rng = ones(1, length (sz)); - rng (dim) = sz (dim); - x = x - repmat (sum (x, dim), rng) / n; - endif - if any (opt == "a") - x = abs (x); - endif - unwind_protect_cleanup - warn_str_to_num = tmp; - end_unwind_protect + if any (opt == "c") + rng = ones (1, length (sz)); + rng(dim) = sz(dim); + x = x - repmat (sum (x, dim), rng) / n; + endif + if any (opt == "a") + x = abs (x); + endif - m = sum(x .^ p, dim) / n; + m = sum (x .^ p, dim) / n; endfunction