Function File: [`p`, `fy`, `cvg`, `outp`] = **nonlin_curvefit** (`f, pin, x, y`)

Function File: [

p,fy,cvg,outp] =nonlin_curvefit(f, pin, x, y, settings)

Frontend for nonlinear fitting of values, computed by a model function, to observed values.

Please refer to the description of

`nonlin_residmin`

. The differences to`nonlin_residmin`

are the additional argumentsx(independent values, mostly, but not necessarily, an array of the same dimensions or the same number of rows asy) andy(array of observations), the returned valuefy(final guess for observed values) instead ofresid, that the model function has a second obligatory argument which will be set toxand is supposed to return guesses for the observations (with the same dimensions), and that the possibly user-supplied function for the jacobian of the model function has also a second obligatory argument which will be set tox.Also, if the setting

`user_interaction`

is given, additional information is passed to these functions. Type`optim_doc ("Common optimization options")`

for this setting.

See also:nonlin_residmin.

The following code

## Example for linear inequality constraints ## (see also the same example in 'demo nonlin_residmin') ## independents and observations indep = 1:5; obs = [1, 2, 4, 7, 14]; ## model function: f = @ (p, x) p(1) * exp (p(2) * x); ## initial values: init = [.25; .25]; ## linear constraints, A.' * parametervector + B >= 0 A = [1; -1]; B = 0; # p(1) >= p(2); settings = optimset ("inequc", {A, B}); ## start optimization [p, model_values, cvg, outp] = nonlin_curvefit (f, init, indep, obs, settings)

Produces the following output

p = 0.62034 0.62034 model_values = 1.1536 2.1451 3.9891 7.4179 13.7941 cvg = 3 outp = scalar structure containing the fields: user_interaction = scalar structure containing the fields: stop = [](0x1) info = {}(0x1) niter = 7

Package: optim