prepareCurveData
Prepare data inputs for curve fitting
Description
[
transforms data, if necessary, for curve fitting with theXOut
,YOut
] = prepareCurveData(XIn
,YIn
)fit
function. TheprepareCurveData
function transforms data as follows:
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.
Remove
NaN
orInf
from data and warn of this removal.Convert nondouble to double and warn of this conversion.
SpecifyXIn
as empty if you want to fit curves toydata against the index. IfXIn
is empty, thenXOut
is a vector of indices intoYOut
. Thefit
function can use the vectorXOut
for thexdata when there is onlyydata.
[
transforms data including weights (XOut
,YOut
,WOut
] = prepareCurveData(XIn
,YIn
,WIn
)WIn
) for curve fitting with thefit
function.
When you generate code from the Curve Fitter app, the generated code includes a call toprepareCurveData
(orprepareSurfaceData
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, theprepareCurveData
function ensures you can use any data that you can fit in the Curve Fitter app, by reshaping if necessary to column doubles and removingNaN
s,Inf
s, or the imaginary parts of complex numbers.