将幂律指数拟合到数据 matlab

Fitting Powerlaw exponential to the data matlab

我有两组数据:y 和 x。例如

y=[5,4,2,1,3,4,...];
x=[1,2,3,4,5,6,...];

我想将它们拟合在函数下方并找到系数 a、b、c、a0、b0、c0、a1、b1 和 c1。 我怎样才能做到这一点? 函数是:

y= a x^b exp(-x/c)

和:

y= a0 x^b0 exp(-x/c0)+ a1 x^b1 exp(-x/c1).
foo_fit = fittype('a*x^b*exp(-x/c)',...
                  'dependent',{'y'},'independent',{'x'},...
                  'coefficients',{'a','b','c'});
res = fit(x',y',foo_fit);

您还可以将递归 n 指定为 fittype 中的 problem 参数(这样您就不必明确说明每个系数 (c0,c1,... ,cn)) 但我不确定 how/if 这是否可能