Interactive Surface Fitting
To interactively fit a surface, follow the steps in this simple example:
Load some data at the MATLAB® command line.
Open the Curve Fitter app.
In the Curve Fitter app, on the Curve Fitter tab, in the Data section, click Select Data. In the Select Fitting Data dialog box, select
zas the X data, Y data, and Z data values, respectively.
The Curve Fitter app creates a default interpolation fit to the data.
Choose a different model type from the fit gallery in the Fit Type section of the Curve Fitter tab.
In the Fit Options pane, try different fit options for your chosen model type.
In the Export section, click Export and select Generate Code.
The Curve Fitter app creates a file in the Editor 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, see Interactive Curve and Surface Fitting.
Programmatic Surface Fitting
To programmatically fit a surface, follow the steps in this simple example:
Load some data.
Create a fit using the
fitfunction, specifying the variables and a model type (in this case
poly23is the model type).
f = fit([x y],z,"poly23")
Plot your fit and the data.
To learn what functions you can use to create and work with fits, see Curve and Surface Fitting.