Hello, Given vectors of data xdata and ydata, I want to find coefficients to find the best fit to some kind of exponential decay equation. Please have a look at my data. I posted it as two vectors at the end of this message, which you can copy and paste into MATLAB. The ydata vs. xdata plot clearly shows a exponential decay. I used the command lsqcurvefit with the function F(p,xdata) = p(1)*exp(p(2)*(xdata+p(3)))
However it fails and I don't know what is wrong woth it. It might be the function or any settings. Its the first time that I use this kind of approach. I only used the command "polyfit" before, but in this case its clearly not a polynomial that I can use to fit the data. I am also wondering if a spherical fit might work better. But I don't know how to set up a function for that kind of fitting.
I pasted the function and my code that I used below:
% Function: function F = myfun(p,xdata) F = p(1)*exp(p(2)*(xdata+p(3))); end