Selecting Data to Fit in Curve Fitter App
To select data to fit in the Curve Fitter app, click Select Data in the Data section on the Curve Fitter tab. You can select variables in your MATLAB® workspace.
To fit curves:
In the Select Fitting Data dialog box, select X Data and Y Data.
Select only Y Data to plot
Yagainst the index
X = 1:length(Y).
To fit surfaces, select X Data, Y Data, and Z Data in the Select Fitting Data dialog box.
In the Select Fitting Data dialog box, you can use the drop-down lists to select any numeric variable in your MATLAB workspace that has more than one element. You can also select a numeric variable that is a column in a table variable. First select the table name, and then select the column name.
Similarly, you can select any numeric variable in your workspace to use as Weights, including a numeric table column.
For curves, the X and Y variables must have the same number of elements. If you specify weights, the weights variable must have the same number of elements as the other data variables.
For surfaces, the X, Y, and Z variables must be either arrays with the same number of elements, or two vectors (X and Y) representing the row and column headers of a matrix Z. If you specify weights, the weights variable must have the same number of elements as the Z variable.
For more information, see Selecting Compatible Size Surface Data.
When you select variables, the Curve Fitter app immediately creates a curve or surface fit with the default settings. If you want to avoid time-consuming refitting for large data sets, you can turn off the automatic behavior. On the Curve Fitter tab, in the Fit section, select Manual.
The Curve Fitter app uses a snapshot of the data you select. Subsequent workspace changes to the data have no effect on your fits. To update your fit data from the workspace, first change the variable selection, and then reselect the variable with the drop-down controls.
Selecting Compatible Size Surface Data
For surface data, in the Curve Fitter app you can select either arrays of the same size or tabular data.
Arrays of the Same Size
Curve Fitter app expects data variables to be the same size. If the sizes are different but the number of elements are the same, then the app reshapes the variables to create a fit and displays a warning in the Results pane. The warning indicates a possible problem with your selected data.
The data variables can form tabular data, where
Y represent the row and column headers of a table (sometimes called
breakpoints) and the
Z values are the table
Sizes are compatible if:
X Data is a vector of length
Y Data is a vector of length
Z Data is a matrix of size
The following table shows an example of data in tabular form with
n = 4 and
m = 3.
surf function, the Curve Fitter app expects
data variables where
length(X) = n,
length(Y) = m,
size(Z) = [m,n]. If the size of
[n,m], the app creates a fit by transposing
provides a warning about the data transformation. You can see the warning in the
Using X data for rows and Y data for columns to match Z data
For an example of tabular data, run the following code.
x = linspace(0,1,7); y = linspace(0,1,9).'; z = bsxfun(@franke,x,y);
If you specify surface weights, specify a variable with the same size as Z. If the sizes are different but the number of elements is the same, the Curve Fitter app reshapes the weights and displays a warning.
Troubleshooting Data Problems
If there are problems with the data you select, you can see messages in the
Results pane. For example, the Curve Fitter app ignores
NaNs, and imaginary components of complex
numbers in the data, and displays messages in the Results pane in these
If you see warnings about reshaping your data or incompatible sizes, read Selecting Compatible Size Surface Data for more information.
The following warning indicates that two or more data points have (x, y) values that are the same or very close together.
Duplicate x-y data points detected: using average of the z
The default interpolant fit type needs to calculate a unique value at that point. You do not need do anything to fix the problem; this warning is just for your information. The Curve Fitter app automatically takes the average z value of any group of points with the same x-y values.
Other problems with your selected data can produce the following error.
Error computing Delaunay triangulation. Please try again with different
For some arrangements of the data, the Curve Fitter app is unable to compute a Delaunay triangulation. Some of the surface interpolation methods (linear, cubic spline, and nearest neighbor) require a Delaunay triangulation of the data. For example, this error can occur when all the data points lie on a straight line in the x-y plane. In this case, the Curve Fitter app is unable to fit a surface to the data. You need to provide more data in order to fit a surface.