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?

Risposte (0)

Richiesto:

il 29 Apr 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by