📄 lmfnlsq.m
字号:
function [xf, SS, cnt, res, XY] = LMFnlsq(varargin)
% LMFNLSQ Solve a set of (over)determined nonlinear equations
% in least squares sense
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A solution is obtained by a Fletcher's version of the Levenberg-Maquardt
% algoritm for minimization of a sum of squares of equation residuals.
% The main domain of LMFnlsq applications is in curve fitting during
% processing of experimental data.
%
% [Xf, Ssq, CNT, Res, XY] = LMFnlsq(FUN,Xo,Options)
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% FUN is a function handle or a function M-file name (string) that
% evaluates m-vector of equation residuals. Residuals are defined
% as res = FUN(x) - y, where y is m-vector of given values.
% Xo is n-vector of initial guesses of solution, unknown parameters,
% Options is an optional set of Name/Value pairs of control parameters
% of the algorithm. It may also be preset by calling:
% Options = LMFnlsq; % for setting default values for Options,
% Options = LMFnlsq('default'); or by a set of Name/Value pairs:
% Options = LMFnlsq('Name',Value, ... ), or updating the Options
% set by calling
% Options = LMFnlsq(Options,'Name',Value, ...).
%
% Name Values {default} Description
% 'Display' {0} Display control
% 0 no display
% k display initial and each k-th iteration;
% 'Printf' name|handle Function for displaying of results; {@printit}
% 'Jacobian' name|handle Jacobian matrix function; {@finjac}
% 'FunTol' {1e-7} norm(FUN(x),1) stopping tolerance;
% 'XTol' {1e-4} norm(x-xold,1) stopping tolerance;
% 'MaxIter' {100} Maximum number of iterations;
% 'ScaleD' Scale control:
% value D = eye(m)*value;
% vector D = diag(vector);
% {[]} D(k,k) = JJ(k,k) for JJ(k,k)>0, or
% = 1 otherwise,
% where JJ = J.'*J
% 'Trace' {0} Tracing control:
% 0 = don't save iteration results x^(k)
% nonzero = save iteration results x^(k)
% 'Lambda' {0} Initial value of parameter lambda
%
% A user may supply his own functions for building Jacobian matrix and for
% displaying intermediate results (corresponding to 'Jacobian' and
% 'Printf' options respectively).
% Not defined fields of the Options structure are filled by default values.
%
% Output Arguments:
% Xf final solution approximation
% Ssq sum of squares of residuals
% Cnt >0 count of iterations
% -MaxIter, no converge in MaxIter iterations
% Res number of calls of FUN and Jacobian matrix
% XY points of intermediate results in iterations
%
% Forms of function callings:
% LMFnlsq % Display help to LMFnlsq
% Options = LMFnlsq; % Settings of Options
% Options = LMFnlsq('default'); % The same as Options = LMFnlsq;
% Options = LMFnlsq(Name1,Value1,Name2,Value2,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -