% -*- texinfo -*- % @deftypefn {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. % % The polynomial coefficients are returned in a row vector. % % The second output is a structure containing the following fields: % % @table @samp % @item R % Triangular factor R from the QR decomposition. % @item X % The Vandermonde matrix used to compute the polynomial coefficients. % @item df % The degrees of freedom. % @item normr % The norm of the residuals. % @item yf % The values of the polynomial for each value of @var{x}. % @end table % % The second output may be used by @code{polyval} to calculate the % statistical error limits of the predicted values. % % When the third output, @var{mu}, is present the % coefficients, @var{p}, are associated with a polynomial in % @var{xhat} = (@var{x}-@var{mu}(1))/@var{mu}(2). % 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} % @end deftypefn

Generated on Sat 16-May-2009 00:04:49 by