| Curve Fitting Toolbox™ | ![]() |
cftool
cftool(xdata,ydata)
cftool(xdata,ydata,w)
cftool opens Curve Fitting Tool, an interactive environment for fitting curves to one-dimensional data.
cftool(xdata,ydata) opens Curve Fitting Tool with predictor data xdata and response data ydata. xdata and ydata must be vectors of the same size. Infs, NaNs, and imaginary parts of complex numbers are ignored in the data.
cftool(xdata,ydata,w) also imports the weight vector w into Curve Fitting Tool for weighting data in subsequent fits. w must be the same length as xdata and ydata.
The Curve Fitting Tool is an interactive environment presented in the form of a graphical user interface. It allows you to
Import data from the MATLAB® workspace
Explore the data graphically
Preprocess the data for fitting using exclusion rules and smoothing
Fit a variety of library or custom models to the data
Generate relevant regression statistics
Post-process the fit through interpolation, extrapolation, differentiation, and integration
Export results back to the MATLAB workspace for further analysis and visualization
The main Curve Fitting Tool interface is shown below.

Clicking the Data, Fitting, Exclude, Plotting, or Analysis buttons opens associated GUIs, described below.
In the figure above, data was imported from the MAT-file census using the Data GUI and fit with a quadratic polynomial using the Fitting GUI. Residuals were displayed in the subplot by selecting View > Residuals > Line Plot.
For a complete example that uses many of these GUIs, refer to Getting Started.
The Data GUI allows you to
Import, name, preview, and delete data sets
Smooth data using a variety of methods
The Data GUI is shown below with the census data loaded.

Refer to Preprocessing Data for more information about the Data GUI.
The Fitting GUI allows you to
Fit your data using parametric or nonparametric models
Set algorithm options for nonlinear fits
Compare coefficients and goodness of fit statistics from different models
Keep track of all data sets and fits in the current session
The Fitting GUI is shown below with the results of fitting the census data.

The Exclude GUI allows you to create exclusion rules for a data set. An exclusion rule identifies data to be excluded while fitting. The excluded data can be individual data points, or a section of predictor or response data.
The Exclude GUI is shown below with the first two points of the census data marked for exclusion.

The Plotting GUI allows you to determine the data sets and fits displayed by Curve Fitting Tool.
The Plotting GUI is shown below with the census data and the fit poly2 checked for display.

The Analysis GUI allows you to
Interpolate, extrapolate, differentiate, or integrate a fit
Display the results of your analysis numerically or in a plot
The Analysis GUI is shown below with a numerical display of the results of extrapolating the census data from the year 2000 to the year 2050 in 10-year increments.

Refer to Analyzing the Fit for an example that uses the Analysis GUI.
![]() | cflibhelp | coeffnames | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |