lsqcurvefit does not change the initial values
13 次查看(过去 30 天)
显示 更早的评论
Hello all,
I am trying retreive parameters from experimental data by fitting 2 differential equations to the data. But I fail already beforehand by fitting a simple exponential equation to data from which I need the parametervalues to continue.
I have xdata and ydata and tried to solve for the three parameters x(1),x(2) and x(3) exactly along the lines of the example 1 in th lsqcurvefit help. But this is what I typed in an got out:
if true
>> fun = @(x,xdata)x(1)*2.868*x(2)/(x(1)*2.868+x(3))*(1-exp(-(x(1)*2.868+x(3))*xdata));
>> x0 = [750 1E-11 5E-5];
>> x = lsqcurvefit(fun,x0,xdata,ydata)
Initial point is a local minimum.
Optimization completed because the size of the gradient at the initial point
is less than the default value of the function tolerance.
<stopping criteria details>
x =
750.0000 0.0000 0.0001
Optimization completed: The final point is the initial point.
The first-order optimality measure, 8.988999e-11, is less than
options.TolFun = 1.000000e-06.
Optimization Metric Options
relative first-order optimality = 8.99e-11 TolFun = 1e-06 (default)
end
I am using MATLAB R2015b - academic license on a Lenovo T420 with Windows 7 Pro SP1.
Am I maybe using the wrong tool for the problem? Is there anybody with a suggestion for improvement?
Best wishes, Ulrich
0 个评论
回答(2 个)
Alan Weiss
2015-11-17
Let us look at your function near your initial values.
(1-exp(-(x(1)*2.868+x(3)) = 1 because x(1) is of order 1000 and x(3) is miniscule.
x(1)*2.868*x(2)/(x(1)*2.868+x(3)) = x(2) because x(1) is of order 1000 and x(3) is miniscule.
So the function does not depend on x(1) or x(3) at all, only on x(2). In fact, you might as well have written
@(x,xdata)x(2)*xdata
Now x(2) is even more miniscule than x(3). So I don't see your function doing anything useful near your initial values--it always returns a miniscule result, just about zero.
Scale your function and/or your initial values better and you might have a chance of seeing improvement.
Alan Weiss
MATLAB mathematical toolbox documentation
7 个评论
Alan Weiss
2015-12-2
Please try my previous suggestion and see if it helps. The reason it might help is that lsqcurvefit tries to estimate the Jacobian of the function by finite differences. Your initial point has such widely varying orders of magnitude between its components that it seems you would want lsqcurvefit to take finite difference steps on the order of each component. So scale the problem and lsqcurvefit might behave better.
This is not a MATLAB limitation, this difference in scale is a problem for any numeric solver.
Alan Weiss
MATLAB mathematical toolbox documentation
Torsten
2015-11-18
Try fitting to the function a*(1-exp(-b*xdata)) with unknown parameters a and b.
From a and b you can determine x(1), x(2) and x(3) in your model that give the same function values for your xdata. This shows you that your model is not a three-parameter model, but a two-parameter model.
Best wishes
Torsten.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!