Custom fit to negative exponential

I am trying to custom fit the data set below into a negative expential in form of "-b*exp(-c*x)+a"
x = [73.1, 94, 100, 130, 150, 184, 192, 200];
y = [0.25, 0.6, 0.65, 0.9, 0.91, 0.94, 0.95, 1];
%Custom fit to -b*exp(-c*x)+a
cftool
But seems as though I am only getting a line.

Answers (2)

Matt J
Matt J on 10 Oct 2021
Edited: Matt J on 10 Oct 2021
Possibly you have to supply a better initial guess. In any case, I would recommend fminspleas (Download) for this problem, which only requires an initial guess for the c parameter.
x = [73.1, 94, 100, 130, 150, 184, 192, 200];
y = [0.25, 0.6, 0.65, 0.9, 0.91, 0.94, 0.95, 1];
funlist= {1 , @(c,x) -exp(-c*x(:)) };
[c,ab]=fminspleas(funlist,0,x,y);
Warning: Rank deficient, rank = 1, tol = 5.024296e-15.
a=ab(1);
b=ab(2);
xup=linspace(min(x),max(x));
fun=@(x) a-b*exp(-c*x(:));
plot(x,y,'o',xup,fun(xup))
Matt J
Matt J on 10 Oct 2021
Edited: Matt J on 10 Oct 2021
You don't need a custom fit for your model. You can use the exp2 model,
Y = a*exp(b*x)+c*exp(d*x)
but put upper and lower bounds of zero on the d parameter (and thus ensure that d=0).
For that matter, it will also help the solver if you put an upper bound of 0 on a and a lower bounds of zero on b and c, since it is obvious from the shape of the data that those bounds should be satisfied at the solution.

Asked:

on 10 Oct 2021

Edited:

on 10 Oct 2021

Community Treasure Hunt

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

Start Hunting!