physical exponential decay and growth processes
Show older comments
Hi All,
I am trying to model the following exponential function for signal decay according to the equation N = N0*e^-1/tau where:
N = signal can vary from 0 to 1;
t = time from 0 to 10 (in seconds);
tau: the time required for N to decrease in size by a factor of 1/e when t = 1.
For my purpose, I hold N0 = 1 and T =1 since I am trying to model different curves at tau = 0.5, tau = 1, tau = 2, etc. to represent how the exponential decay changes as result of changes in tau.
I have tried the following code but I get an exp growth curve instead, which I don't understand why since the exp is negative. Of course, if I remove the negative sign, I get a decay curve, which is not the intended purpose of the formula:
N = linspace(0,1,11);
t = linspace(0,10,11);
tau = linspace(0.5,10,11);
N0= 1;
N = N0*exp(-1./tau);
plot(t,N,'-')
thanks for your help
Accepted Answer
More Answers (1)
You need to put t into the equation for N, and just plot one curve for each tau. You were varying N with tau and then plotting vs. t, which is wrong:
N = linspace(0,1,11);
t = linspace(0,10,11);
tau = linspace(0.5,10,11);
N0= 1;
for k = 1 : length(tau)
N = N0*exp(-t ./ tau(k));
plot(t,N,'-')
hold on;
end
grid on;
2 Comments
Felix
on 22 Nov 2021
Image Analyst
on 22 Nov 2021
You're welcome. If it works, then could you click the "Accept this answer" link? Thanks in advance.
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
