Oliver Range
Oliver Range

Reputation: 365

Fitting Powerlaw exponential to the data matlab

I have two sets of data: y and x. For exampe

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

I want to fit them below functions and find coefficients a,b,c,a0,b0,c0,a1,b1 and c1. How can I do that? Functions are:

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

and:

y= a0 x^b0 exp(-x/c0)+ a1 x^b1 exp(-x/c1).

Upvotes: 2

Views: 287

Answers (1)

Brendan Frick
Brendan Frick

Reputation: 1025

foo_fit = fittype('a*x^b*exp(-x/c)',...
                  'dependent',{'y'},'independent',{'x'},...
                  'coefficients',{'a','b','c'});
res = fit(x',y',foo_fit);

You can also specify a recursive n as the problem parameter in fittype (so you don't have to explicitly state each coefficient (c0,c1,...,cn)) but I'm not sure how/if this is possible

Upvotes: 1

Related Questions