Prepare data inputs for curve fitting
[XOut,YOut,WOut] = prepareCurveData(XIn,YIn,WIn)
Return data as columns regardless of the input shapes. Error if the number of elements do not match. Warn if the number of elements match, but the sizes differ.
Convert complex to real (remove imaginary parts) and warn of this conversion.
data and warn of this removal.
Convert nondouble to double and warn of this conversion.
XIn as empty if you want to fit
curves to y data against the index. If
XOut is a vector of indices into
fit function can use the
XOut for the x data
when there is only y data.
When you generate code from the Curve Fitting app, the generated
code includes a call to
prepareSurfaceData for surface fits).
You can call the generated file from the command line with your original
data or new data as input arguments, to recreate your fits and plots.
If you call the generated file with new data, the
ensures you can use any data that you can fit in the Curve Fitting
app, by reshaping if necessary to column doubles and removing
or the imaginary parts of complex numbers.
X data variable for curve fitting, of any numeric type.
Y data variable for curve fitting, of any numeric type.
Weights variable for curve fitting, of any numeric type.
X data column variable prepared for curve fitting, of type double.
Y data column variable prepared for curve fitting, of type double.
Weights column variable prepared for curve fitting, of type double.
The following commands load the example
titanium data in which
y are row vectors. Attempting to use rows as inputs to the
fit function produces an error. The
prepareCurveData function reshapes
y to columns for use with the
[x,y] = titanium(); [x,y] = prepareCurveData(x,y);
Create and plot a fit using the reshaped data.
f = fit(x,y,'smoothingspline'); plot(f,x,y)