幂律函数的曲线拟合y = a(x ^ b)+ c

时间:2017-03-10 16:54:28

标签: matlab curve-fitting power-law

我是MATLAB的新手,我正试图通过数据集拟合幂律。我一直在尝试使用isqcurvefit功能,但我不确定如何继续,因为通过谷歌发现的说明对初学者来说太复杂了。我想从方程y = a(x ^ b)+ c推导出值b和c,我们将非常感谢任何建议。谢谢。

1 个答案:

答案 0 :(得分: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)