-1

I'm trying to fit my data into an exponential curve with Matlab but I'm getting a very bad fit. I am a very amateur programmer so I don't really know how to use the cftool and fit options (I tried). How do I change the values to optain a better fit?

See image in link below

Results of the fit: value a should be negative

  • Does this answer help you? http://stackoverflow.com/questions/5393001/fit-exponential-curve-through-data-points-in-matlab/17267385#17267385 – Adiel Mar 30 '16 at 06:53

1 Answers1

1

The curve fitting tool is powerful, but it sometimes needs a bit of help. In practice, what cftool does is takes the initial guess for your variables and then tries to iteratively improve on those values by changing them slightly each time and then re-evaluating how good the fit is. Once small changes to the parameters only make the fit worse, it returns its result. For more complicated equations (e.g. exponential fits), this can sometimes converge to a local minimum rather than the global minimum, which is what you're seeing.

This is resolved by setting it up for the equation you want (in your case, an exponential fit as you have done) and then clicking Fit Options and playing with the parameters in there. Most defaults in there are good for most intents and purposes, but you should play around with the Starting values for your variables, and the lower and upper bounds that these variables can take on. This is done at the bottom of the Fit Options dialog. As you point out, you know that the b is negative in your case, so you could for example set the b StartPoint to a negative value, and set the upper bound to 0. You can also probably make a few sensible guesses at the a startpoint and all the other upper and lower bounds.

enter image description here

RPM
  • 1,704
  • 12
  • 15