Main Content

数据选择

选择数据以适合曲线拟合应用程序

要选择要适合的数据,请使用曲线拟合应用程序的下拉列表来选择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

当您选择变量,曲线拟合的应用mmediately creates a curve or surface fit with the default settings. If you want to avoid time-consuming refitting for large data sets, you can turn offAuto 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.

选择ing Compatible Size Surface Data

For surface data, in Curve Fitting app you can select either相同尺寸的矩阵orTable Data

相同尺寸的矩阵

曲线拟合应用预计输入尺寸是相同的。如果大小不同但元素的数量相同,则该工具将重新装入输入以创建合适并显示警告Results窗格。警告表示所选数据可能的问题。

Table Data

Table data意思是Xandy代表表的行和列标题(有时调用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)= mandsize(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窗格。例如,曲线拟合应用忽略了InfS,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)相同或非常靠近在一起。默认的Interpolant适合类型需要在该点计算唯一的值。您不需要做任何事情来解决问题,此警告只是为了您的信息。曲线拟合应用程序自动取自具有相同X-Y值的任何点组的平均z值。

您所选数据的其他问题可以产生以下错误:

Error computing Delaunay triangulation. Please try again with different data.
数据的某些安排使得曲线拟合应用程序无法计算Delaunay三角测量。四个表面插值方法中的三个(线性,立方体和最近)需要数据的Delaunay三角测量。可能导致此错误的数据示例是所有数据在X-Y中的直线上所示的情况。在这种情况下,曲线拟合应用程序无法拟合到数据的表面。您需要提供更多数据以适应表面。

注意

如果您处于调试模式,则禁用数据选择。退出调试模式以更改数据选择。