Custom fit to negative exponential

조회 수: 26 (최근 30일)
Timothy Tuong
Timothy Tuong 2021년 10월 10일
편집: Matt J 2021년 10월 10일
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.

답변 (2개)

Matt J
Matt J 2021년 10월 10일
편집: Matt J 2021년 10월 10일
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 2021년 10월 10일
편집: Matt J 2021년 10월 10일
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.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by