The answer is trivial:
Let you have one set of 12 values of lefthand side, say in the column vector hmnp. Make a function for evaluation of differences (residuals) between righthand sides and lefthand sides, say resid.m in the form
function r = resid(x)
r = [x(1)+x(2)*p+ ... +(x(11)+x(12)*p)*n] - hmnp;
Here x(1) up to x(6) correspond C1 to C6 and x(7) up to x(12) correspon D1 up to D6. The simplest call of the function to solve the problem could be
[x,ssq,cnt] = LMFnlsq2('resid',x0);
A better way would be
[x,ssq,cnt] = LMFnlsq2('resid',x0,'Display',-50);
Of course that you have to supply a good estimate of the solution - coefficients C1, ..., D6. It is very important that you are able to do it, say from a nature of your experiment. The elements of x0 must not be zeros!
Since THe solution of your task has as many unknowns as equations, there is no
any degree of freedom. In consequence of it the solution should yield ssq->0.
I wish you good luck.
15 Jul 2014
Solution of one or more nonlinear equations in the least squares sense.
Hi, Balda. Good day.
My curve fitting prblem is to calibrate the model like this:
The parameters to be estimate are C1,C2,C3,C4,C5,C6,D1,D2,D3,D4,D5,D6. And we have obtained 12 sets of data of h(m,n,p). So how to write the L-M expression using the LMFnlsq2.m ?