Time constant of exponential decay

88 views (last 30 days)
friet
friet on 2 Mar 2018
Commented: John D'Errico on 3 Mar 2018
Hello Matlab,
I have those two equations of exponential decay with time constant of the first one tu1=3800 sec. I plot those graphs and then from the graph, when I find the 36% decay of the initial value, I read different value tu2=5397. Can anyone help me what I am missing here?
y0=2;
tu1=3800;
tu2=1200;
t=0:1:10000;
y=y0*exp(-t/tu1)+ 0.4;
y2=(y0/2)*exp(-t/tu2)+0.5;
plot(t,y,t,y2)
legend('1','2')
  3 Comments
John D'Errico
John D'Errico on 2 Mar 2018
What you are doing with that 36% point only makes sense if you have a PURE exponential decay. You don't.

Sign in to comment.

Answers (2)

John D'Errico
John D'Errico on 2 Mar 2018
Edited: John D'Errico on 2 Mar 2018
As Walter pointed out, you don't have a purely exponential model. Yet, this is way easier than you think to solve. Two lines of code to recover the time constant. ;-)
Presume the model is a negative exponential, plus an unknown constant, sampled at an arithmetic sequence in t.
dt = t(2) - t(1);
dy = diff(y);
So assume the model was
y(t) = y0*exp(-t/tc) + yinf
Then when we used diff, it kills off the unknown additive constant. (i.e., the asymptote as t-->infinity.) We will get something like
y0*(exp(-(t + dt)/tc) - exp(-t/tc)) = y0*exp(-t/tc)*(1 - exp(-dt/tc))
Here, dt is quite small compared to tc, but both dt and tc are fixed, thus not a function of t. We don't know either y0 or tc, YET. Take the log.
log(diff(y)) = log(y0*(1-exp(-dt/tc))) - t/tc
Again, the first term is constant, thus not a function of t. While we don't know what that constant is, we don't care, as this part is targeted at solving for tc. The second term is linear in t.
We solve for tc using polyfit.
P1 = polyfit(t(2:end),log(-diff(y)),1)
P1 =
-0.00026316 -7.5495
tc = -1/P1(1)
tc =
3800
Yup. That looks familiar.
To recover the unknowns from the second series,
P2 = polyfit(t(2:end),log(-diff(y2)),1)
P2 =
-0.00083333 -7.0897
tc2 = -1/P2(1)
tc2 =
1200
Ok. That really was pretty easy. Can we now recover the constants y0 and the asymptote at infinity? Easy peasy too. Just one more line. Oddly enough, we use polyfit once more.
polyfit(exp(-t/tc),y,1)
ans =
2 0.4
For the second curve...
polyfit(exp(-t/tc2),y2,1)
ans =
1 0.5
I think you should recognize each of those coefficients for each dataset.
Such a versatile tool, that polyfit. We used it twice, fitting a straight line fit each time, yet we solved a nonlinear curve fitting problem, recovering not only the rate constant, but the asymptote at infinity as well as the multiplicative constant out front.
Kind of pretty. (Yes, I played a bit fast and loose with the statistics here.)
  5 Comments
John D'Errico
John D'Errico on 3 Mar 2018
For the case of a curve with a non-zero asymptote, I gave it to you already! READ MY ANSWER. There I showed you a very simple code to compute that time constant, requiring all of two lines of MATLAB code. In fact, I also gave you a complete derivation thereof.

Sign in to comment.


Walter Roberson
Walter Roberson on 2 Mar 2018
The time constant tu1=3800 applies to a pure exponential. You do not have a pure exponential: you have an exponential plus a constant. If you look at 3800 you will see 0.88 plus the constant.
  1 Comment
friet
friet on 2 Mar 2018
So at t=3800, i got 1.136. and this is not equal to 0.88+0.5=1.38.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!