FUNCTION REFERENCE

lsqnonlin

Nonlinear least squares: minimise sum(fun(x).^2), optionally within bounds.

Nonlinear least squares: minimise sum(fun(x).^2), optionally within bounds.

Syntax

x = lsqnonlin(fun, x0)

Syntax

x = lsqnonlin(fun, x0, lb, ub)

Syntax

x = lsqnonlin(fun, x0, lb, ub, options)

Syntax

[x, resnorm, residual, exitflag, output] = lsqnonlin(...)

Levenberg-Marquardt with a trust region on the scaled step (Moré's method).

With bounds, x0 is moved into [lb, ub], variables that the gradient presses

against a bound are held there, and each step is projected back into the

box. The output message reports projection of x0; lb > ub is an error naming

the bound. lb or ub may be [] (no bound). The Jacobian is estimated by finite

differences (stepping inwards at a bound), or is the second output of fun

when SpecifyObjectiveGradient is true. residual is fun(x), resnorm its sum of

squares. Limits: MaxIterations 400, MaxFunctionEvaluations 100*numel(x0).

exitflag: 1 first-order optimality within OptimalityTolerance (relative to

its starting value, at least 1), 2 short step, 3 relative change of resnorm

below FunctionTolerance, 0 limit reached, -3 trust-region collapse without

an improved point.

Example

x = lsqnonlin(@(x) [x(1) - 3; x(2) + 1; x(1)*x(2) - 1], [1 1], [0 0], [2 2])   % [2 0.2]

Differences from MATLAB: Algorithm must be 'levenberg-marquardt' (projected

onto the bounds); no linear or nonlinear constraints;

outputs lambda and jacobian are not returned.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.