MATLAB: How to fit a curve to this plot

curvecurve fittingfitfitcurveplotplot fitting

I want to fit a curve to the plot below. I tried smoothingspline and it didn't work.

Best Answer

(continuing from the comments under the question)
To get a good fit, you need to make sure you're working with the correct function with the necessary parameters and starting off with good initial guesses for the parameter values. It looks like your data are sigmoidal so fitting the data to a sigmoid is a good start!
From Wiki (link),
  • e = the natural logarithm base (also known as Euler's number),
  • x0 = the x-value of the sigmoid's midpoint,
  • L = the curve's maximum value, and
  • k = the steepness of the curve.
You may have to add additional parameters that scale the sigmoid to your data.
I'd code that function up in matlab, plot it out, and play around with the parameters until it looks like your data. Then I'd fit your data to that function with the initial parameter guesses set to whatever you decided was similar to your data.
Curve fitting is a process and there's never really 1 solution to any set of noisy data. Play around with it and always assess the error of your fit.