prepareSurfaceData
Prepare data inputs for surface fitting
Syntax
Description
[
transforms data, if necessary, for surface fitting with theXOut
,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 thefit
function.
UseprepareSurfaceData
if your data is not in column vector form. For example, you have 3 matrices. You can also useprepareSurfaceData
if you have grid vectors, wherelength(XIn) = n, length(YIn) = m
andsize(ZIn) = [m,n]
. You must process grid vector data for use with thefit
function by usingprepareSurfaceData
. 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 useprepareSurfaceData
. You can specify variables in a MATLAB table as inputs to thefit
function using the formtablename.varname
.
When you generate code from the Curve Fitter app, the generated code includes a call toprepareSurfaceData
(orprepareCurveData
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, theprepareCurveData
function ensures you can use any data that you can fit in the Curve Fitter app, by reshaping if necessary and removingNaN
s,Inf
s, or the imaginary parts of complex numbers.