Curve Fitting
Interactive Curve Fitting
To interactively fit a curve, follow the steps in this simple example:
Load some data at the MATLAB®command line.
loadhahn1
Open the Curve Fitter app.
curveFitter
In the Curve Fitter app, on theCurve Fittertab, in theDatasection, clickSelect Data. In the Select Fitting Data dialog box, select
temp
as theX Datavalue andthermex
as theY Datavalue.The Curve Fitter app creates a default polynomial fit to the data.
Choose a different model type from the fit gallery in theFit Typesection of theCurve Fittertab.
In theFit Optionspane, try different fit options for your chosen model type.
In theExportsection, clickExportand selectGenerate Code.
曲线更应用在编辑器中创建一个文件containing MATLAB code to recreate the currently selected fit and its opened plots in your interactive session.
For more information about fitting curves in the Curve Fitter app, seeInteractive Curve and Surface Fitting.
Programmatic Curve Fitting
To programmatically fit a curve, follow the steps in this simple example:
Load some data.
loadhahn1
Create a fit using the
fit
function, specifying the variables and a model type (in this caserat23
is the model type).f = fit(temp,thermex,"rat23")
Plot your fit and the data.
plot(f,temp,thermex) f(600)
To learn what functions you can use to create and work with fits, seeCurve and Surface Fitting.