Solves nonlinear least-squares curve fitting problems of the form

lsqnonlin

Solve nonlinear least-squares (nonlinear data-fitting) problems

Equation

Solves nonlinear least-squares curve fitting problems of the form

Syntax

x = lsqnonlin(fun,x0)
x = lsqnonlin(fun,x0,lb,ub)
x = lsqnonlin(fun,x0,lb,ub,options)
x = lsqnonlin(problem)
[x,resnorm] = lsqnonlin(...)
[x,resnorm,residual] = lsqnonlin(...)
[x,resnorm,residual,exitflag] = lsqnonlin(...)
[x,resnorm,residual,exitflag,output] = lsqnonlin(...)
[x,resnorm,residual,exitflag,output,lambda] = lsqnonlin(...)
[x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(...) 

Description

lsqnonlin solves nonlinear least-squares problems, including nonlinear data-fitting problems.

Rather than compute the value  (the sum of squares), lsqnonlin requires the user-defined function to compute the vector-valued function

Then, in vector terms, you can restate this optimization problem as

where x is a vector and f(x) is a function that returns a vector value.

x = lsqnonlin(fun,x0) starts at the point x0 and finds a minimum of the sum of squares of the functions described in funfun should return a vector of values and not the sum of squares of the values. (The algorithm implicitly sums and squares fun(x).)

x = lsqnonlin(fun,x0,lb,ub) defines a set of lower and upper bounds on the design variables inx, so that the solution is always in the range lb  x  ub.

x = lsqnonlin(fun,x0,lb,ub,options) minimizes with the optimization options specified in the structure options. Use optimset to set these options. Pass empty matrices for lb and ub if no bounds exist.

x = lsqnonlin(problem) finds the minimum for problem, where problem is a structure described inInput Arguments.

Create the structure problem by exporting a problem from Optimization Tool, as described inExporting Your Work.

[x,resnorm] = lsqnonlin(...) returns the value of the squared 2-norm of the residual at x:sum(fun(x).^2).

[x,resnorm,residual] = lsqnonlin(...) returns the value of the residual fun(x) at the solution x.

[x,resnorm,residual,exitflag] = lsqnonlin(...) returns a value exitflag that describes the exit condition.

[x,resnorm,residual,exitflag,output] = lsqnonlin(...) returns a structure output that contains information about the optimization.

[x,resnorm,residual,exitflag,output,lambda] = lsqnonlin(...) returns a structure lambda whose fields contain the Lagrange multipliers at the solution x.

[x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(...) returns the Jacobian offun at the solution x.

  • Note:   If the specified input bounds for a problem are inconsistent, the output x is x0 and the outputs resnorm and residual are [].

    Components of x0 that violate the bounds lb ≤ x ≤ ub are reset to the interior of the box defined by the bounds. Components that respect the bounds are not changed.

Input Arguments

Function Arguments contains general descriptions of arguments passed into lsqnonlin. This section provides function-specific details for funoptions, and problem:

fun

The function whose sum of squares is minimized. fun is a function that accepts a vector x and returns a vector F, the objective functions evaluated at x. The function fun can be specified as a function handle to a file:

x = lsqnonlin(@myfun,x0)

where myfun is a MATLAB function such as

function F = myfun(x)
F = ...            % Compute function values at x

fun can also be a function handle for an anonymous function.

x = lsqnonlin(@(x)sin(x.*x),x0);

If the user-defined values for x and F are matrices, they are converted to a vector using linear indexing.

  • Note   The sum of squares should not be formed explicitly. Instead, your function should return a vector of function values. See Examples.

If the Jacobian can also be computed and the Jacobian option is 'on', set by

options = optimset('Jacobian','on')

the function fun must return, in a second output argument, the Jacobian value J, a matrix, at x. By checking the value of nargout, the function can avoid computing J when fun is called with only one output argument (in the case where the optimization algorithm only needs the value of F but not J).

function [F,J] = myfun(x)
F = ...          % Objective function values at x
if nargout > 1   % Two output arguments
   J = ...   % Jacobian of the function evaluated at x
end

If fun returns a vector (matrix) of m components and x has length n, where nis the length of x0, the Jacobian J is an m-by-n matrix where J(i,j) is the partial derivative of F(i) with respect to x(j). (The Jacobian J is the transpose of the gradient of F.)

options

Options provides the function-specific details for the options values.

problem

objective

Objective function

x0

Initial point for x
lb Vector of lower bounds
ub Vector of upper bounds

solver

'lsqnonlin'

options

Options structure created with optimset

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值