How can I fit an exponential curve?

70 ビュー (過去 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 件のコメント
Milad Naderloo
Milad Naderloo 2020 年 11 月 28 日
I apperciate! it works:)

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by