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.

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.

Demonstration 1

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.6203
   0.6203

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
    lambda =

      scalar structure containing the fields:

        lower =

           0
           0

        upper =

           0
           0

        eqlin = [](0x0)
        ineqlin = 269.24
        eqnonlin = [](1x0)
        ineqnonlin = [](1x0)

Package: optim