Main Content

Surface Fitting

Interactive Surface Fitting

To interactively fit a surface, follow the steps in this simple example:

  1. Load some data at the MATLAB®command line.

    loadfranke

  2. Open the Curve Fitter app.

    curveFitter

  3. In the Curve Fitter app, on theCurve Fittertab, in theDatasection, clickSelect Data. In the Select Fitting Data dialog box, selectx,y, andzas theX Data,Y Data, andZ Datavalues, respectively.

    The Curve Fitter app creates a default interpolation fit to the data.

  4. Choose a different model type from the fit gallery in theFit Typesection of theCurve Fittertab.

  5. In theFit Optionspane, try different fit options for your chosen model type.

  6. In theExportsection, clickExportand selectGenerate Code.

    曲线更应用在编辑器中创建一个文件containing MATLAB code to recreate the currently selected fit and its opened plots in your interactive session.

For more information about fitting surfaces in the Curve Fitter app, seeInteractive Curve and Surface Fitting.

Programmatic Surface Fitting

To programmatically fit a surface, follow the steps in this simple example:

  1. Load some data.

    loadfranke
  2. Create a fit using thefitfunction, specifying the variables and a model type (in this casepoly23is the model type).

    f = fit([x y],z,"poly23")
  3. Plot your fit and the data.

    plot(f,[x y],z)

To learn what functions you can use to create and work with fits, seeCurve and Surface Fitting.

See Also

|

Related Topics