changeset 3190:70eb3f4136cd

[project @ 1998-10-19 22:37:56 by jwe]
author jwe
date Mon, 19 Oct 1998 22:37:57 +0000
parents bef7b73c0724
children e4f4b2d26ee9
files scripts/ChangeLog scripts/polynomial/polyfit.m
diffstat 2 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@
+Mon Oct 19 17:26:35 1998  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* polynomial/polyfit.m: Just use the \ operator to handle the
+	least-squares solution.
+
 Thu Sep  3 12:40:47 1998  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* strings/str2num.m: If eval returns a string, return an empty matrix.
--- a/scripts/polynomial/polyfit.m
+++ b/scripts/polynomial/polyfit.m
@@ -51,19 +51,9 @@
   x = reshape (x, l, 1);
   y = reshape (y, l, 1);
 
-  ## Unfortunately, the economy QR factorization doesn't really save
-  ## memory doing the computation -- the returned values are just
-  ## smaller.
-
-  ## [Q, R] = qr (X, 0);
-  ## p = flipud (R \ (Q' * y));
-
-  ## XXX FIXME XXX -- this is probably not so good for extreme values of
-  ## N or X...
-
   X = (x * ones (1, n+1)) .^ (ones (l, 1) * (0 : n));
 
-  p = (X' * X) \ (X' * y);
+  p = X \ y;
 
   if (nargout == 2)
     yf = X * p;