prepareSurfaceData
Prepare data inputs for surface fitting
Syntax
Description
[
transforms data, if necessary, for surface fitting with the XOut
, YOut
, ZOut
] = prepareSurfaceData(XIn
,
YIn
, ZIn
)fit
function. The function
transforms data as follows:
For grid vectors, transform row (
) and column (YIn
XIn
) headers into arraysYOut
andXOut
that are the same size asZIn
. Warn ifXIn
andYIn
are reversed.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 are different.
Convert complex to real (remove imaginary parts) and warn of this conversion.
Remove
NaN
orInf
from data and warn of this removal.Convert nondouble to double and warn of this conversion.
[
transforms data including weights (XOut
, YOut
, ZOut
, WOut
] = prepareSurfaceData(XIn
,
YIn
, ZIn
, WIn
)WIn
) for surface fitting
with the fit
function.
Use prepareSurfaceData
if your data is not in column
vector form. For example, you have 3 matrices. You can also use
prepareSurfaceData
if you have grid vectors, where
length(XIn) = n, length(YIn) = m
and size(ZIn) =
[m,n]
. You must process grid vector data for use with the
fit
function by using
prepareSurfaceData
. If you use the Curve Fitter app,
you can select grid vector data and it automatically converts the data for
you.
If your data is in a MATLAB® table, you do not need to use
prepareSurfaceData
. You can specify variables in a
MATLAB table as inputs to the fit
function using the
form tablename.varname
.
When you generate code from the Curve Fitter app, the generated code includes
a call to prepareSurfaceData
(or prepareCurveData
for curve
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 prepareCurveData
function ensures you can use any data that you can fit in the Curve Fitter app,
by reshaping if necessary and removing NaN
s,
Inf
s, or the imaginary parts of complex numbers.
Examples
Input Arguments
Output Arguments
Version History
Introduced in R2010b