How to fit exponential function to data by appointing custom fittype

5 Ansichten (letzte 30 Tage)
Robert Voeten
Robert Voeten am 14 Sep. 2016
I am trying to fit an exponential model to my data in the form of a*(1-exp(-b*x)). After some searching i found the following code:
x=data(:,1);
y=data(:,2);
g = fittype('a*(1-exp(-b*x))');
xx = linspace(min(x),max(x),length(x));
f0 = fit(x,y,g,'StartPoint',[[ones(size(x)), -exp(-x)]\y);
plot(x,y,'o',xx,f0(xx),'r-');
Here 'data' (at least a part of it) is presented (txt file) in the attachment for an increasing and decreasing system. However, i can't seem to get it working properly. for f0 an error pops up regarding the amount of start point, but after putting
f0 = fit(x,y,g,'StartPoint',[[ones(size(x)), -exp(-x)]);
an error pops up stating 'Matrix must be column or row vector'
please advise.
Thanks in advance

Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by