Problem with fitting exponential using lsqnonlin
显示 更早的评论
I am trying to fit some data (attached) using an equation of the form
y = t(1)*exp(-x/t(2)) + t(3)
However, my code:
ub = [inf 1 inf ];
lb = [-inf 1e-5 -inf ];
t0 = [1/2 1/2 40 ];
fun_lsq = @(t)(t(1)*exp(-x/t(2)) + t(3) - y);
fun = @(t)(t(1)*exp(-x/t(2)) + t(3) );
t = lsqnonlin(fun_lsq,t0, lb, ub);
Doesn't seem to fit the data very well, and I think this is because the lsqnonlin function doesn't change the inital guess for the time constant term t(2) very much:
initialguess: [0.5000 0.5000 40]
fitparam: [7.5671e-10 0.4700 -5.4190e-10]
Does anyone have a way to produce a better fit?
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Numeric Solvers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!