The function is an improved version of the function LMFnlsq widely tested on the nonlinear regression, curve fitting and identification problems. Better description is in the complementing file LMFnlsq2test.pdf.
Warning: The option 'Display' is changed for better control of intermediate results output. See help LMFnlsq2.
Build M-function, say resid.m, for evaluation of problem residuals:
function res = resid(p)
global t Y Wp % Wp = penalty weight
% If you wish to work with the native names of variables (not with the elements of the sought parameters p(i), use the following command:
[A,B,C1,C2,m,w,Tc] = deal2('_elm_',p); % deal2 is the function from the File Exchange
Tct = Tc - t;
lTt = log(Tct);
res = [A + B*Tct.^m + C1*cos(w*lTt) + C2*sin(w*lTt) - Y
The user should choose propper weight(s) of penalties expressing constraints put on parameters.
Thanks for your reply. My curve fitting prblem is to calibrate the model like this:
The parameters to be estimate is A,B,C1,C2,m,w,Tc,
and the Constraints is:
B<0, |C1|<1, |C2|<1, Tc>max(t(i)), 0.1<m<0.9, 6<w<13， So how to write the L-M expression using the LMFnlsq2.m ?
Yes, you may make curve-fitting with constraints, if you introduce convenient penalty functions, which generate additional elements in the vector of residuals. It has been used in the solution of the Problem 3, Constrained Rosenbrock valey, described in the file LMFnlsq2test.m.
[A,v] = getAv(FUN,JAC,x,r,bdx);
SS = r'*r;
15 Apr 2013
Display of intermediate results has been improved to fulfill better users' requirements.
Thanks Jose's detailed study of the code, small bugs were repaired and the code made more clear.
16 Apr 2013
Repaired several bugs found by Jose. Improved description of the function and of the demo program LMFnlsq2test.
22 Apr 2013
The new version of the function is a slight modification of the recent update. One statement, dated 2012-12-01, has been commented out because of its erroneous function under certain circumstances. The function is now fast and much more stable.
23 Apr 2013
Improved the printout of results. The previous versions did not display the final solution if the iteration count were not integer multiple of required step of printing.