Curve Fitting Toolbox
Curve Fitting Toolbox provides the most widely used techniques for fitting curves and surfaces to data, including linear and nonlinear regression, splines and interpolation, and smoothing. The toolbox supports options for robust regression to fit data sets that contain outliers. All algorithms can be accessed through functions or the Curve Fitting app.
The Curve Fitting app simplifies common tasks that include:
Working at the command line lets you develop custom functions for analysis and visualization. These functions enable you to:
Curve Fitting Toolbox provides a simple intuitive syntax for command-line fitting, as in the following examples:
fittedmodel = fit([X,Y], Z, 'poly11');
fittedmodel = fit(X, Y, 'fourier2');
fittedmodel = fit([Time,Temperature], Energy, 'cubicinterp');
fittedmodel = fit([Time,Temperature], Energy, 'lowess', ‘span’, 0.12);
The results of a fitting operation are stored in an object called
“fittedmodel.” Postprocessing analysis, such as plotting, evaluation, and calculating integrals and derivatives, can be performed by applying a method to this object, as in these examples:
differentiate(fittedmodel, X, Y)
Curve Fitting Toolbox lets you move interactive fitting to the command line. Using the app, you can automatically generate MATLAB code. You can also create fit objects with the app and export them to the MATLAB workspace for further analysis.
The toolbox supports over 100 regression models, including:
All of these standard regression models include optimized solver parameters and starting conditions to improve fit quality. Alternatively, you can use the Custom Equation option to specify your own regression model.
In the Curve Fitting app you can generate fits based on complicated parametric models by using a drop-down menu. At the command line you can access the same models using intuitive names.
The regression analysis options in Curve Fitting Toolbox enable you to:
Curve Fitting Toolbox supports a variety of interpolation methods, including B-splines, thin plate splines, and tensor product splines. Curve Fitting Toolbox provides functions for advanced spline operations, including break/knot manipulation, optimal knot placement, and data-point weighting.
You can represent a polynomial spline in ppform and B-form. The ppform describes the spline in terms of breakpoints and local polynomial coefficients, and is useful when the spline will be evaluated extensively. The B-form describes a spline as a linear combination of B-splines, specifically the knot sequence and B-spline coefficients.
Curve Fitting Toolbox also supports other types of interpolation, including:
The Curve Fitting Toolbox commands for constructing spline approximations accommodate vector-valued gridded data, enabling you to create curve and surfaces in any number of dimensions.
Smoothing algorithms are widely used to remove noise from a data set while preserving important patterns. Curve Fitting Toolbox supports both smoothing splines and localized regression, which enable you to generate a predictive model without specifying a functional relationship between the variables.
Develop a predictive model without specifying a function that describes the relationship between variables.
Curve Fitting Toolbox supports localized regression using either a first-order polynomial (lowess) or a second-order polynomial (loess). The toolbox also provides options for robust localized regression to accommodate outliers in the data set. Curve Fitting Toolbox also supports moving average smoothers such as Savitzky-Golay filters.
Curve Fitting Toolbox supports a comprehensive workflow that progresses from exploratory data analysis (EDA) through model development and comparison to postprocessing analysis.
You can plot a data set in two or three dimensions. The toolbox provides options to remove outliers, section data series, and weight or exclude data points.
Curve Fitting Toolbox lets you automatically center and scale a data set to normalize the data and improve fit quality. The Center and scale option can be used when there are dramatic differences in variable scales or the distance between data points varies across dimensions.
Curve Fitting Toolbox lets you fit multiple candidate models to a data set. You can then evaluate goodness of fit using a combination of descriptive statistics, visual inspection, and validation.
Curve Fitting Toolbox provides a wide range of descriptive statistics, including:
The Table of Fits lists all of the candidate models in a sortable table, enabling you to quickly compare and contrast multiple models.
The toolbox enables you to visually inspect candidate models to reveal problems with fit that are not apparent in summary statistics. For example, you can:
Curve Fitting Toolbox supports validation techniques that help protect against overfitting. You can generate a predictive model using a training data set, apply your model to a validation data set, and then evaluate goodness of fit.
Once you have selected the curve or surface that best describes your data series you can perform postprocessing analysis. Curve Fitting Toolbox enables you to:
The following examples show how postprocessing at the command line applies intuitive commands to the objects created from a fitting operation:
EnergyConsumption = fittedmodel(X, Y)
EnergySurface = plot(fittedmodel)
Volume_Under_Surface = quad2d(fittedmodel, Min_X, Max_X, Min_Y, Max_Y)
Gradient = differentiate(fittedmodel, X,Y)
confidence intervals: Confidence_Intervals = confint(fittedmodel)