Main Content

Curve Fitter

Fit curves and surfaces to data

Description

The Curve Fitter app provides a low-code interface where you can interactively fit curves and surfaces to data and view plots.

With the Curve Fitter app, you can:

  • Create, plot, and compare multiple fits.

  • Use linear or nonlinear regression, interpolation, smoothing, and custom equations.

  • View goodness-of-fit statistics, display confidence intervals and residuals, remove outliers, and assess fits with validation data.

  • Automatically generate code to fit and plot curves and surfaces, or export fits to the workspace for further analysis.

  • Export a curve or surface fit to a Simulink® lookup table. For an example, see Export Fit from Curve Fitter App to Simulink Lookup Table.

Curve Fitter app

Open the Curve Fitter App

  • MATLAB® Toolstrip: On the Apps tab, under Math, Statistics and Optimization, click the app icon.

  • MATLAB command prompt: Enter curveFitter.

Programmatic Use

expand all

curveFitter opens the Curve Fitter app or brings focus to the app if it is already open.

curveFitter(x,y) opens the Curve Fitter app and creates a curve fit to the data in x and y. The x and y arguments must be numeric, have two or more elements, and have the same number of elements.

curveFitter(x,y,z) opens the Curve Fitter app and creates a surface fit to the data in x, y, and z. The x, y, and z arguments must be numeric, have two or more elements, and have compatible sizes. The sizes are compatible if either of the following statements is true.

  • x, y, and z are arrays with the same number of elements.

  • x and y are vectors of length n and m, respectively, and z is an m-by-n matrix.

curveFitter(x,y,[],w) opens the Curve Fitter app and creates a curve fit with weights w. The weights w must be a numeric array and have the same number of elements as x and y.

curveFitter(x,y,z,w) opens the Curve Fitter app and creates a surface fit with weights w. The weights w must be a numeric array and have the same number of elements as z.

curveFitter(filename) loads the Curve Fitter session in filename into the Curve Fitter app. filename must have the extension .sfit.

Tips

  • When selecting data for fitting curves or surfaces in Curve Fitter, you can specify to use table variables. On the Curve Fitter tab, in the Data section, click Select Data. The app opens a dialog box. For each data variable (X data, Y data, Z data, or Weights), first select the table name and then select the name of the column variable that you want to use.

    You can also specify validation data using table variables. Click Validation Data in the Data section of the Curve Fitter tab to open the Select Validation Data dialog box.

    To programmatically open the Curve Fitter app and create a curve fit to x and y, where x and y are variables in table tbl, enter curveFitter(tbl.x,tbl.y) at the MATLAB command line. Similarly, enter curveFitter(tbl.x,tbl.y,tbl.z) to create a surface fit in the Curve Fitter app for the table variables x, y, and z.

Version History

Introduced before R2006a

expand all

See Also

Functions