| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| R2010b Documentation → Curve Fitting Toolbox |
| Contents | Index |
| Learn more about Curve Fitting Toolbox |
| On this page… |
|---|
Using Center and Scale Setting |
Surface Fitting Tool provides a selection of fit types and settings that you can alter to try to improve your fit. Try the defaults first, then experiment with other settings. This section describes how to use the available fit types and settings.
You can try a variety of settings within a single fit tab, and you can also create multiple fits to compare. When you create multiple fits you can compare different fit types and settings side by side in the Surface Fitting Tool. See Fitting Multiple Surfaces and Comparing Surface Fits.
Select a fit category from the drop-down list in the Surface Fitting Tool:
Interpolant — for interpolating a surface through the data points.
Interpolant is the default fit type.
Polynomial — for linear regression
Lowess — for local smoothing regression
Custom Equation — for nonlinear regression
Each fit category has specific settings that appear when you choose a fit type. The settings for each fit category are described in the following sections.
For all fit categories, look in the Results pane to see the model terms, the values of the coefficients, and the goodness-of-fit statistics.
Tip If there are problems with your fit, messages appear in the Results pane to help you identify better settings. |
Each fit category (except Custom equation) shares the Center and scale option. When you select the Center and scale option, the Surface Fitting Tool refits with the data centred and scaled, by applying the Normalize setting to the variables. Normalize is an input argument to the fitoptions function. See the fitoptions reference page.
Generally it is a good idea to normalize inputs (also known as predictor data), which can alleviate numerical problems with variables of different scales. For example, suppose your inputs are engine speed with a range of 500–4500 r/min and engine load with a range of 0–1. Then, Center and scale generally improves the fit because of the great difference in scale between the two inputs. However, if your inputs are in the same units or similar scale (e.g., eastings and northings for geographic data), then Center and scale is less useful. When you normalize inputs with the Center and scale option, the values of the fitted coefficients change when compared to the original data.
If you are fitting a surface to estimate coefficients, or the coefficients have physical significance, clear the Center and scale check box. The Surface Fitting Tool plots use the original scale with or without the Center and scale option.
The Interpolant fit category fits an interpolating surface that passes through all the data points. This fit category uses the MATLAB GRIDDATA function. The settings are shown below.

You can specify the Methods setting: Linear, Cubic, Nearest, or Biharmonic (v4). For details on these methods, see the documentation for the MATLAB GRIDDATA function.
Tip If your input variables have different scales, turn the Center and scale option on and off to see the difference in the surface fit. Normalizing the inputs can have a strong influence on the results of the triangle-based (i.e., piecewise Linear and Cubic interpolation) and Nearest-neighbour interpolation methods. |
The Polynomial fit uses the Curve Fitting Toolbox polynomial library model. This library model is an input argument to the fit and fittype functions. See thefitoptions reference page.
The Polynomial fit type fits a polynomial in x and y.

You can specify the following options:
The degree for the x and y inputs (maximum of 5 in each case). The degree of the polynomial is the maximum of x and y degrees. See Defining Polynomial Terms for Polynomial Fit Category.
The robust linear least-squares fitting method to use (Off, LAR, or Bisquare). For details, see Robust on the fitoptions reference page.
Set bounds or exclude terms by clicking Fit Options. You can exclude a term by setting its bounds to zero.
Tip If your input variables have very different scales, turn the Center and scale option on and off to see the difference in the surface fit. |
You can control the terms to include in the polynomial model by specifying the Degrees for the x and y inputs. If i is the degree in x and j is the degree in y, the total degree of the polynomial is the maximum of i and j. The degree of x in each term is less than or equal to i, and the degree of y in each term is less than or equal to j.
For example, if you specify an x degree of 3 and a y degree of 2, the model name is poly32. The model terms follow the form shown in the following table.
| Degree of term | 0 | 1 | 2 |
|---|---|---|---|
| 0 | 1 | y | y2 |
| 1 | x | xy | xy2 |
| 2 | x2 | x2y | |
| 3 | x3 |
The total degree of the polynomial cannot exceed the maximum of i and j. In this example, terms such as x3y and x2y2 are excluded because their degrees sum to more than 3. In both cases, the total degree is 4.
You can exclude any term by clicking the Fit Options button, and setting the bounds to zero for any terms you want to remove. Look in the Results pane to see the model terms, the values of the coefficients, and the goodness-of-fit statistics.
The Lowess fit category uses locally weighted linear regression to smooth data.

You can specify the following options:
Select Linear or Quadratic in the drop-down to specify the type of Polynomial model to use in the regression. . In Curve Fitting Toolbox, lowess fitting uses a linear polynomial, while loess fitting uses a quadratic polynomial. For more information on these two types of smoothing fit, see Local Regression Smoothing.
The Span as a percentage of the total number of data points in the data set. The toolbox uses neighboring data points defined within the span to determine each smoothed value. This role of neighboring points is the reason why the smoothing process is called "local."
The Robust linear least-squares fitting method you want to use (Off, LAR, or Bisquare). The local regression uses the Robust option. Using the Robust weight function can make the process resistant to outliers. For details, see Robust on the fitoptions reference page.
The fit type name lowess derives from the term "locally weighted scatter plot smooth." The process is weighted because the toolbox defines a regression weight function for the data points contained within the span. In addition to the regression weight function, the Robust option is a weight function that can make the process resistant to outliers. For more information, see Local Regression Smoothing.
Tip If your input variables have very different scales, turn the Center and scale option on and off to see the difference in the surface fit. Normalizing the inputs can have a strong influence on the results of a Lowess fitting. |
You can use the Custom Equation fit category to define your own equations. An example is provided. The example custom equation displays when you select Custom Equation from the drop-down, as shown here.

You can enter any valid MATLAB expression in terms of x and y .
You can save your custom equations as part of your saved Surface Fit Tool sessions.
Your function may execute a number of times, both during fitting and during preprocessing before fitting. Be aware of this if you are using functions with side effects such as writing data to a file, or displaying diagnostic information to the Command Window.
![]() | Interactive Surface Fitting Examples | Fitting Multiple Surfaces | ![]() |
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |