Mercurial > hg > octave-nkf
diff scripts/polynomial/polyfit.m @ 14104:614505385171 stable
doc: Overhaul docstrings for polynomial functions.
* mkpp.m, mpoles.m, pchip.m, poly.m, polyaffine.m, polyder.m, polyfit.m,
polygcd.m, polyint.m, polyout.m, polyreduce.m, polyval.m, polyvalm.m, ppder.m,
ppval.m, residue.m, roots.m, spline.m, unmkpp.m: Improve docstrings.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 23 Dec 2011 20:09:27 -0800 |
parents | 5b49cafe0599 |
children | b8d9530e940e |
line wrap: on
line diff
--- a/scripts/polynomial/polyfit.m +++ b/scripts/polynomial/polyfit.m @@ -21,11 +21,12 @@ ## @deftypefnx {Function File} {[@var{p}, @var{s}] =} polyfit (@var{x}, @var{y}, @var{n}) ## @deftypefnx {Function File} {[@var{p}, @var{s}, @var{mu}] =} polyfit (@var{x}, @var{y}, @var{n}) ## Return the coefficients of a polynomial @var{p}(@var{x}) of degree -## @var{n} that minimizes the least-squares-error of the fit. +## @var{n} that minimizes the least-squares-error of the fit to the points +## @code{[@var{x}, @var{y}]}. ## ## The polynomial coefficients are returned in a row vector. ## -## The second output is a structure containing the following fields: +## The optional output @var{s} is a structure containing the following fields: ## ## @table @samp ## @item R @@ -53,7 +54,7 @@ ## Where @var{mu}(1) = mean (@var{x}), and @var{mu}(2) = std (@var{x}). ## This linear transformation of @var{x} improves the numerical ## stability of the fit. -## @seealso{polyval, residue} +## @seealso{polyval, polyaffine, roots, vander, zscore} ## @end deftypefn ## Author: KH <Kurt.Hornik@wu-wien.ac.at> @@ -80,8 +81,6 @@ error ("polyfit: N must be a non-negative integer"); endif - y_is_row_vector = (rows (y) == 1); - ## Reshape x & y into column vectors. l = numel (x); x = x(:); @@ -98,7 +97,7 @@ if (nargout > 1) yf = v*p; - if (y_is_row_vector) + if (isrow (y)) s.yf = yf.'; else s.yf = yf;