Prepare data inputs for surface fitting
[
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 arrays
YOut
and XOut
that are the
same size as ZIn
. Warn if XIn
and YIn
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
or Inf
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 Curve Fitting 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 Curve Fitting 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 Curve Fitting app, by
reshaping if necessary and removing NaN
s,
Inf
s, or the imaginary parts of complex numbers.