Products & Services Solutions Academia Support User Community Company

Learn more about Curve Fitting Toolbox   

Selecting Fit Settings

Introduction

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.

Selecting Fit Category

Select a fit category from the drop-down list in the Surface Fitting Tool:

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.

Using Center and Scale Setting

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.

Using Interpolant Fit Category

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.

Using Polynomial Fit Category

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:

Defining Polynomial Terms for Polynomial Fit Category

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 term012
01yy2
1xxyxy2
2x2x2y 
3x3  

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.

Using Lowess Fit Category

The Lowess fit category uses locally weighted linear regression to smooth data.

You can specify the following options:

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.

Using Custom Equation Fit Category

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.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS