Next: , Previous: nonlin_residmin, Up: Residual optimization


2.2 Function nonlin_curvefit() for curve fitting

In curve fitting, the model function computes values from a constant set of `independents', and the intention is to minimize the differences of these computed values to a constant set of `observations'. This can be done with nonlin_residmin, but it is more convenient to use nonlin_curvefit, which cares for passing the constant `independents' to the model function and for calculating the differences to the constant `observations'.

However, if in some optimization problem you notice that you end up with passing dummy-values for the `independents' and zeros for the `observations', you can more naturally use nonlin_residmin instead of nonlin_curvefit.

— 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 arguments x (independent values, mostly, but not necessarily, an array of the same dimensions or the same number of rows as y) and y (array of observations), the returned value fy (final guess for observed values) instead of resid, that the model function has a second obligatory argument which will be set to x and 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 to x.

See also: nonlin_residmin.

Also, if the setting user_interaction is given, additional information is passed to these functions, see

Common optimization options.