我是 MATLAB 新手,我正在尝试通过数据集拟合幂律。我一直在尝试使用 isqcurvefit 函数,但我不确定如何继续,因为通过 Google 找到的说明对于初学者来说太复杂了。我想从方程 y = a(x^b)+c 导出值 b 和 c,任何建议都将不胜感激。谢谢。
问问题
712 次
1 回答
0
您可以使用以最小二乘意义lsqcurvefit
通过测量数据点拟合非线性曲线,如下所示:
% constant parameters
a = 1; % set the value of a
% initial guesses for fitted parameters
b_guess = 1; % provide an initial guess for b
c_guess = 0; % provide an initial guess for c
% Definition of the fitted function
f = @(x, xdata) a*(xdata.^x(1))+x(2);
% generate example data for the x and y data to fit (this should be replaced with your real measured data)
xdata = 1:10;
ydata = f([2 3], xdata); % create data with b=2 and c=3
% fit the data with the desired function
x = lsqcurvefit(f,[b_guess c_guess],xdata,ydata);
%result of the fit, i.e. the fitted parameters
b = x(1)
c = x(2)
于 2017-03-11T09:55:27.547 回答