MATLAB Answers

0

fitting the double exponential decay curve to data and finding paprameters

Asked by Parul Tewatia on 18 May 2018
Latest activity Commented on by Ameer Hamza
on 7 Jun 2018

I have extracted data from a florescence decay graph. the equation used has two double exponential parameters and other 2 parameters. the equation is in the matlab code. Now I want to fit the curve to this given equation so i have all the parameters. As the flouresnce data was in percentage i converted it to quantities by multiplying by 6. I worked on an example by matlab https://se.mathworks.com/help/optim/examples/nonlinear-data-fitting.html but I am not able to plot the fitting with the fplot command something is going wrong as it gives an error. Also I dont want local minima but global minima, but i am novice so dont know how to use this fitvector. But most importantly the problem i am facing is with initial parameter guess. what is a good way to find these guesses. Also I read somewhere its a good approach to divide problem into two, as the decay is quite fast initially but is quiet linear after some time. Reading too much stuff i am quite confused. I have attached both my code and data plot. thanks for the help. much appreciated Parul

  0 Comments

Sign in to comment.

1 Answer

Answer by Ameer Hamza
on 18 May 2018
 Accepted Answer

Since you are trying curve fitting by minimizing least square error, lsqcurvefit() is a better choice. Try the following

t = xdata;
y = ydata;
F = @(x,xdata)x(1)*exp(-x(2)*xdata) + x(3)*exp(-x(4)*xdata);
x0 = [300 0.005 1 0] ;
xunc = lsqcurvefit(F, x0, t, y);
tlist = linspace(min(t), max(t));   % Plot Finer Resolution
figure(1)
plot(t,y,'ro')
title('Data points')
hold on
plot(tlist, F(xunc,tlist), '-r', 'LineWidth', 2)
hold off

In your code, you were also specifying the wrong first variable for function F in plot statement. The fit seems quite well.