How can I fit an exponential curve?

조회 수: 87 (최근 30일)
Milad Naderloo
Milad Naderloo 2020년 11월 28일
댓글: Milad Naderloo 2020년 11월 28일
Hi,
I have the following data: x= [35.668 34.448 33.317 30.357 27.598]; y = [180 504 1260 10300 80900];
How do I fit an exponential curve of the form y=a-b*exp(-c*x) to my data? Is there any Matlab function to do that? and possibly print out the equation on the graph.
Thanks in advance!

채택된 답변

John D'Errico
John D'Errico 2020년 11월 28일
편집: John D'Errico 2020년 11월 28일
x = [35.668 34.448 33.317 30.357 27.598];
y = [180 504 1260 10300 80900];
plot(x,y,'o-')
First, recognize you have only 5 data points. Any expectation of a good estimate of the parameters is wildly optimistic.
Next, recognize that your y variable varies by a factor of 400 over the curve. That means the point at x = 27.598 will have a HUGE impact on the estimates. Typically, this means you might need to consider other error structures, for example a proportional error might make more sense.
ft = fittype('a-b*exp(-c*x)','indep','x')
mdl = fit(x',y',ft,'start',[50 -1e13 1])
mdl =
General model:
mdl(x) = a-b*exp(-c*x)
Coefficients (with 95% confidence bounds):
a = -752.6 (-4674, 3169)
b = -1e+13 (-7.311e+13, 5.311e+13)
c = 0.6749 (0.4492, 0.9006)
plot(mdl)
hold on
plot(x,y,'o-')
The first thing you should recognize is the coefficient b is NEGATIVE. I don't know why you think your model should be of the form
y=a-b*exp(-c*x)
In fact, that model, where you SUBTRACT the exponential term results in a NEGATIVE value of b.
So the resulting model looks like this:
y = -752 + 1e13*exp(-0.6749*x)
You should also see the model put confidence bounds on a that are huge, [-4674,3169]. See that a, which is the asymptote as x -- inf, is NEGATIVE. So this model predicts your function will go below zero for large x.
You need to recognize your data is literally worthless to estimate the parameters. You don't have enough data. And for some reason, you don't understand the shape that negative sign on b implies.

추가 답변 (1개)

M.Many
M.Many 2020년 11월 28일
You can use cftool to fit curves, or use the Basic fitting tool when you plot the curve (in the Tool tab of the figure), but the latter doesn't do exponential fitting.
  댓글 수: 1
Milad Naderloo
Milad Naderloo 2020년 11월 28일
Thank you for cftool, it is easeir there for fitting!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by