Statistics Toolbox | ![]() ![]() |
Nonlinear least-squares data fitting by the Gauss-Newton method
Syntax
Description
beta = nlinfit(X,y,FUN,beta0)
estimates the coefficients of a nonlinear function using least squares. y
is a vector of response (dependent variable) values. Typically, X
is a design matrix of predictor (independent variable) values, with one row for each value in y
. However, X
can be any array that FUN
can accept. FUN
is a function of the form
where beta
is a coefficient vector, and X
is the design matrix. FUN
returns a vector yhat
of fitted y
values. beta0
is a vector containing initial values for the coefficients.
returns the fitted coefficients, [beta,r,J] = nlinfit(X,y,
FUN,beta0)
beta
, the residuals, r
, and the Jacobian, J
. You can use these outputs with nlpredci
to produce error estimates on predictions, and with nlparci
to produce error estimates on the estimated coefficients.
Example
Find the coefficients that best fit the data in reaction.mat
. The chemistry behind this data set deals with reaction kinetics as a function of the partial pressure of three chemical reactants: hydrogen, n-pentane, and isopentane.
The hougen
function uses the Hougen-Watson model for reaction kinetics to return the predicted values of the reaction rate.
load reaction
betafit = nlinfit(reactants,rate,@hougen,beta)
betafit = 1.2526 0.0628 0.0400 0.1124 1.1914
See Also
hougen
, nlintool
, nlparci
, nlpredci
![]() | ncx2stat | nlintool | ![]() |