如何使用Matlab曲线拟合工具拟合指数函数?

How to fit the exponential function using Matlab curve fitting tool?

我有一个 table,在 Matlab 中有 2 列,c1 和 c2。我想使用曲线拟合工具将指数方程拟合到我的数据中。

现在我的代码中有这个: cftool(c1,c2);

此代码将打开 cftool 并拟合 多项式 曲线!但是我希望它是 Exponential 曲线!我该怎么做?

关键是让数据适合您的工作空间,并首先选择 X 数据Y 数据。然后下拉菜单将显示 "Exponential" 作为选项。来自 this documentation page:

  1. Open the Curve Fitting app by entering cftool. Alternatively, click Curve Fitting on the Apps tab.
  2. In the Curve Fitting app, select curve data (X data and Y data, or just Y data against index).
    Curve Fitting app creates the default curve fit, Polynomial.
  3. Change the model type from Polynomial to Exponential.

查看cftool for fitting your data, select File > Generate Code after you've configured all of the options and are satisfied with the results. You can then use and modify this code for your application instead calling cftool. In the case of a simple exponential fit, it looks like the fit function is used with options specified via fittype and fitoptions使用的代码。

这是你想要的吗?

f = fit(x,y,'exp1');

您还可以自定义:

myfit = fittype('a*u+b*exp(n*u)',...
            'problem','n',...
            'independent','u');

使用f=fit(x,y,'myfit'); You can read about it here and here