要选择适合数据的数据,请使用曲线拟合应用中的下拉列表来选择MATLAB中的变量®工作区。
适合曲线:
选择x数据andy数据。
仅选择y数据绘制y
反对索引(x = 1:长度(y)
)。
To fit surfaces, selectx数据,,,,y数据andz数据。
您可以使用曲线拟合应用下拉列表在MATLAB工作区中选择任何数字变量(具有多个元素)。
同样,您可以选择工作空间中的任何数字数据权重。
For curves, X, Y, and Weights must be matrices with the same number of elements.
For surfaces, X, Y, and Z must be either:
具有相同数量元素的矩阵
表格的数据
对于表面,重量必须具有与Z相同数量的元素。
有关更多信息,请参见选择ing Compatible Size Surface Data。
当您选择变量时,曲线拟合应用程序会立即创建曲线或默认设置的曲线拟合。如果您想避免为大数据集进行耗时的改装,可以关闭Auto fit通过清除复选框。
笔记
The Curve Fitting app uses a snapshot of the data you select. Subsequent workspace changes to the data have no effect on your fits. To update your fit data from the workspace, first change the variable selection, and then reselect the variable with the drop-down controls.
For surface data, in Curve Fitting app you can select either相同尺寸的矩阵orTable Data。
曲线拟合应用程序预计输入的大小相同。如果尺寸不同,但元素数量相同,则该工具会重塑输入以创建拟合,并在此处显示警告Results窗格。警告表示您选择的数据可能存在问题。
Table data意思是X
andy
表示表的行和列标题(有时称为breakpoints),表中的值是z
output.
尺寸是兼容的,如果:
X是长度的向量n
。
y是长度的向量m
。
z是大小的2D矩阵[M,N]
。
下表显示了一个与表格的示例n = 4
andM = 3
。
x(1) |
x(2) |
x(3) |
x(4) |
|
---|---|---|---|---|
y(1) |
Z(1,1) |
z(1,2) |
z(1,3) |
z(1,4) |
y(2) |
z(2,1) |
z(2,2) |
z(2,3) |
Z(2,4) |
y(3) |
Z(3,1) |
Z(3,2) |
Z(3,3) |
Z(3,4) |
Like the冲浪
功能,曲线拟合应用程序期望输入长度(x)= n
,,,,长度(y)= m
andsize(Z) = [m,n]
。如果大小z
是[n,m]
,该工具创建合适但首先转换z
and warns about transforming your data. You see a warning in theResults窗格如下以下示例:
使用x输入进行行,y输入以匹配z输出矩阵。
对于适当的示例表数据,运行以下代码:
x = linspace( 0, 1, 7 ); y = linspace( 0, 1, 9 ).'; z = bsxfun( @franke, x, y );
For surface fitting at the command line with the合身
功能,使用准备表面
function if your data is in table form.
如果指定表面重量,则分配一个与Z相同的输入。如果大小不同,但元素数量相同,则曲线拟合应用程序会重塑权重并显示警告。
If there are problems with the data you select, you see messages in theResults窗格。例如,曲线拟合应用程序忽略Inf
S,南
s和数据中复数的虚构组件,您会在该消息中看到消息Results在这些情况下。
If you see warnings about reshaping your data or incompatible sizes, read选择ing Compatible Size Surface Data以获取信息。
如果您看到以下警告:Duplicate x-y data points detected: using average of the z values
,这意味着在两个或多个数据点中,输入值(x,y)相同或非常接近。默认的插值拟合类型需要在此点计算唯一值。您不需要做任何解决问题的事情,此警告仅用于您的信息。曲线拟合应用程序会自动采用具有相同X-Y值的任何组点的平均Z值。
所选数据的其他问题可能会产生以下错误:
Error computing Delaunay triangulation. Please try again with different data.
笔记
如果您处于调试模式,则数据选择将禁用。退出调试模式更改数据选择。