[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
polyfit: add a third output argument, mu [PATCH]
From: |
Shaun Jackman |
Subject: |
polyfit: add a third output argument, mu [PATCH] |
Date: |
Mon, 30 Jun 2008 11:52:56 -0700 |
User-agent: |
Thunderbird 2.0.0.14 (X11/20080421) |
The following patch adds a third output argument, mu for compatibility with
Matlab. I made an effort to update the documentation, but I'm not familiar with
Octave's documentation system.
Cheers,
Shaun
2008-06-30 Shaun Jackman <address@hidden>
* polynomial/polyfit.m (polyfit): Add a third output argument,
mu, for compatibility. If three output arguments are requested,
the input argument x is shifted and scaled before fitting.
--- /opt/octave-3.0.1/share/octave/3.0.1/m/polynomial/polyfit.m.orig 2008-04-25
09:17:07.000000000 -0700
+++ /opt/octave-3.0.1/share/octave/3.0.1/m/polynomial/polyfit.m 2008-06-30
11:15:46.000000000 -0700
@@ -51,6 +51,10 @@
## @item yf
## The values of the polynomial for each value of @var{x}.
## @end table
+##
+## If three output arguments are requested, the input argument @var{x}
+## is transformed before fitting by @code{(x - mu(1)) / mu(2)},
+## where @code{mu(1) = mean(x)} and @code{mu(2) = std(x)}.
## @end deftypefn
## Author: KH <address@hidden>
@@ -72,6 +76,12 @@
error ("polyfit: n must be a nonnegative integer");
endif
+ if (nargout > 2)
+ mu(1) = mean(x);
+ mu(2) = std(x);
+ x = (x - mu(1)) / mu(2);
+ endif
+
y_is_row_vector = (rows (y) == 1);
l = length (x);
- polyfit: add a third output argument, mu [PATCH],
Shaun Jackman <=