How can I fit an exponential curve?

87 visualizaciones (últimos 30 días)
Milad Naderloo
Milad Naderloo el 28 de Nov. de 2020
Comentada: Milad Naderloo el 28 de Nov. de 2020
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!

Respuesta aceptada

John D'Errico
John D'Errico el 28 de Nov. de 2020
Editada: John D'Errico el 28 de Nov. de 2020
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.

Más respuestas (1)

M.Many
M.Many el 28 de Nov. de 2020
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 comentario
Milad Naderloo
Milad Naderloo el 28 de Nov. de 2020
Thank you for cftool, it is easeir there for fitting!

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by