Main Content

生成代码和导出适合工作区

Generating Code from the Curve Fitting App

您可以生成和使用matlab®来自曲线拟合应用程序中的交互式会话的代码。通过这种方式,您可以将您的交互式分析转换为可重复使用的函数,用于多个数据集的批处理。您可以使用生成的文件而无需修改,或者您可以根据需要编辑和自定义文件。

To generate code for all fits and plots in your Curve Fitting app session follow these steps:

  1. 选择File>Generate Code

    曲线拟合应用程序从您的会话生成代码,并在MATLAB编辑器中显示该文件。该文件包括当前会话中的所有适合和绘图。该文件捕获以下信息:

    • Names of fits and their variables

    • 适合设置和选项

    • 绘图

    • 用于创建适合的曲线和表面拟合物体和方法:

      • A cell-array ofCFIT.orSFIT.代表适合的物体

      • 具有良好信息的结构阵列。

  2. 保存文件。

要重新创建您的Fits和Plots,请使用原始数据作为输入参数调用命令行中的文件。您还可以使用新数据调用该文件。

For example, enter:

[fitresult, gof] =myfilename.(a,b,c)
哪里一种B.那一种ndC一种re your variable names, andmyfilename.是文件名。

Calling the file from the command line does重建你的曲线拟合程序和会话。当you call the file, you get the same plots you had in your Curve Fitting app session in standard MATLAB figure windows. There is one window for each fit. For example, if your fit in the Curve Fitting app session displayed main, residual and contour plots, all three plots appear in a single figure window.

曲线拟合功能

曲线和表面配合物体(CFIT.一种ndSFIT.)将结果存储在拟合操作中,使得易于绘制和分析命令行。

了解有适合合作的可用功能,请参阅Curve and Surface Fitting

Exporting a Fit to the Workspace

To export a fit to the MATLAB workspace, follow these steps:

  1. 使用以下方法选择一个合适并将其保存到Matlab Workspace:

    • Right-click the fit listed in the Table of Fits and selectSavemyfitname.to Workspace

    • 在曲线拟合应用中选择一个适合图形并选择Fit>保存到工作区

    The Save Fit to MATLAB Workspace dialog box opens.

  2. Edit the names as appropriate. If you previously exported fits, the toolbox automatically adds a numbered suffix to the default names so there is no danger of overwriting them.

  3. 通过选择复选框,选择要导出的选项。复选框选项如下:

    • Save fit to MATLAB object named适合tedmodel— This option creates aCFIT.orSFIT.对象,它封装将曲线或表面拟合到数据的结果。您可以在命令行中检查拟合系数,例如:

      FittedModel线性模型Poly22:FittedModel1(x,y)= p00 + p10 * x + p01 * y + p20 * x ^ 2 ... + p11 * x * y + p02 * y ^ 2系数(具有95%的置信度界限):P00 = 302.1(247.3,356.8)P10 = -1395(-1751,-1039)P01 = 0.03525(0.01899,0.05151)P20 = 1696(1099,2293)P11 = -0.1119(-0.1624,-0.06134)P02 = 2.36E-006(-8.72E-007,5.593E-006)
      你也可以对待CFIT.orSFIT.对象作为制作预测或评估X(或x和y)值的函数的函数。看看CFIT.一种ndSFIT.reference page.

    • 拯救适合Matlab Struct的善良善意- 此选项创建一个结构阵列,其中包含有关适合的统计信息,例如:

      善良= SSE:0.0234 RSQUARE:0.9369 DFE:128 adjrsquare:0.0135

    • 将Fit输出保存到MATLAB STRACT命名输出- 此选项创建一个结构阵列,其中包含诸如观察号和参数,残差等的信息。例如:

      输出= numobs:134 numparam:6残差:[134x1 double]雅各比:[134x6 double]退出氟:1算法:'QR分解和解决'迭代:1

      注意

      适合的善良一种nd输出阵列是输出的适合function. See the适合reference page.

  4. 点击OK将拟合选项保存到工作区。

将拟合保存到工作区后,您可以使用Fit PostProcessing功能。例如,看到分析您在工作区中最合适的。有关更多信息和函数列表,请参阅适合后处理

Related Topics