MATLAB: How to define ‘options’ for the FIT command in Curve Fitting Toolbox 3.0 (R2010b)

fitMATLAB

I would like to use the FIT command to perform curve fitting on my data. I also want to able to select different options such as 'CubicSplineInterpolan'. How can I do this?

Best Answer

In order to define an "options" structure, define it after specifying the 'libname' parameter. 'libname' is the function that FIT uses to find a best fit to the data. However, "options" parameter tells the FIT what kind of fitting option or algorithm that FIT should use for a specific 'libname'.
For example:
options = fitoptions('Method','CubicSplineInterpolant');
[magcubicsplinecdf,G5] = fit(x1',y1','poly3',options);
plot([0:2.5E-5:1],magscubicplinecdf([0:2.5E-5:1]),'g-')
In this particular example, FITOPTIONS is used in order to specify 'options' parameter to the FIT. In FIT, 'poly3' is used as a fitting function.
You can find more information about each of FIT and FITOPTIONS in the following:
<http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/fit.html>
<http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/fitoptions.html>