Main Content

prepareSurfaceData

Prepare data inputs for surface fitting

Description

example

[xout,YOut,ZOut] = prepareSurfaceData(XIn,YIn,ZIn)如有必要,将数据转换为与fitfunction. The function transforms data as follows:

  • For grid vectors, transform row (YIn) and column (XIn) headers into arraysYOutxoutthat are the same size asZIn。Warn ifXInYInare reversed.

  • 返回数据作为列,无论输入形状如何。如果元素数不匹配,则错误。警告元素数量是否匹配,但大小不同。

  • Convert complex to real (remove imaginary parts) and warn of this conversion.

  • RemoveNaN或者inffrom data and warn of this removal.

  • Convert nondouble to double and warn of this conversion.

[xout,YOut,ZOut,WOut] = prepareSurfaceData(XIn,YIn,ZIn,)transforms data including weights () for surface fitting with thefitfunction.

UseprepareSurfaceData如果您的数据不在列矢量形式中。例如,您有3个矩阵。您也可以使用prepareSurfaceDataif you have grid vectors, where长度(xin)= n,长度(yin)= msize(ZIn) = [m,n]。您必须处理网格向量数据以与fit通过使用功能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®表,您不需要使用prepareSurfaceData。You can specify variables in a MATLAB table as inputs to thefitfunction using the formtablename.varname

When you generate code from the Curve Fitter app, the generated code includes a call toprepareSurfaceData(orprepareCurveDatafor 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, theprepareCurveDatafunction ensures you can use any data that you can fit in the Curve Fitter app, by reshaping if necessary and removingNaNs,infs, or the imaginary parts of complex numbers.

Examples

collapse all

Create some data that is unsuitable for the fit function without preprocessing, because it is nondouble, noncolumn, and contains someNaninfvalues.

x = int32(1:4);y = int32(1:5);z = rand(5,4);z(13)= inf;z(3)= nan;

Use theprepareSurfaceDatato convert rows to columns, nondoubles to doubles, and removeNaninf

[xo,yo,zo] = prepareSurfaceData(x,y,z);

该功能显示与曲线钳工应用中选择此数据相同的警告。警告告诉您如何处理数据以适合fitfunction.

Usewhosto check that theprepareSurfaceDataconverted the variables to column vectors that are doubles.

whosxoyozo

Input Arguments

collapse all

X数据变量准备表面拟合,specified as a scalar, a vector or a matrix.

Data Types:double

Y data variable to prepare for surface fitting, specified as a scalar, a vector or a matrix.

Data Types:double

z数据变量以准备表面拟合, specified as a scalar, a vector or a matrix.

Data Types:double

Weights variable to prepare for surface fitting, specified as a scalar, a vector or a matrix.

Data Types:double

Output Arguments

collapse all

X data column variable prepared for surface fitting, returned as a vector.

Data Types:double

Y data column variable prepared for surface fitting, returned as a vector.

Data Types:double

z数据列变量为表面拟合准备,返回为矢量。

Data Types:double

Weights column variable prepared for surface fitting, returned as a vector.

Data Types:double

Version History

Introduced in R2010b