Symbolic expression for exponential decay

To calculate an exponential decay with a single constant τ, , why do you need to multiply the following by a heaviside function as below if you want a symbolic expression? Also, how would you do this for multiple constants, i.e., given a vector of the constants?
syms t real
tau = 0.1;
f(t) = exp(-t/tau)*heaviside(t);
I am referring to the answer here.

 採用された回答

Voss
Voss 2022 年 7 月 10 日

0 投票

exp(-t/tau) is an exponential function of t, whose value is 1 at t = 0, whose value is less than 1 for t > 0, and whose value is greater than 1 for t < 0.
Here's a plot of exp(-t/tau) without the heaviside(t):
syms t real
tau = 0.1;
f(t) = exp(-t/tau);
fplot(f,[-1 1])
Notice the very large values f(t) has when t < 0.
Look at those same values on a log scale:
fplot(f,[-1 1])
set(gca(),'YScale','log')
Notice the function goes through 1 at t = 0.
In order to have the function start at t = 0 and discard the values for t < 0, you can use the heaviside() function, which has value 1 for t > 0 and value 0 for t < 0 (its value is 1/2 at t = 0):
fplot(heaviside(t),[-1 1],'LineWidth',2)
Multiplying exp(-t/tau) by heaviside(t) has the effect of zeroing-out the function for t < 0:
f(t) = exp(-t/tau)*heaviside(t);
fplot(f,[-1 1])

5 件のコメント

L'O.G.
L'O.G. 2022 年 7 月 10 日
編集済み: L'O.G. 2022 年 7 月 10 日
@Voss Thanks, and for my related question about if there are multiple values for tau -- would that just be symsum of exp(-t/tau)*heaviside(t) where tau is now a vector ? i.e. symsum(exp(-t/tau)*heaviside(t),tau,1,N) where N is the end of the series doesn't seem quite right, since the sum is over
Paul
Paul 2022 年 7 月 10 日
編集済み: Paul 2022 年 7 月 10 日
Also, we must have tau > 0 for the CTFT integral to converge.
syms t tau w real
f(t) = exp(-t/tau)*heaviside(t)
f(t) = 
fourier(f(t),t,w)
ans = 
Because it's possible that tau < 0 and yhe signal blows up for t>0, Matlab couldn't find a solution. So we need to add tau > 0 as an additional assumption
assumeAlso(tau,'positive');
fourier(f(t),t,w)
ans = 
and we get the expected result. Of course, this only matters if you keep tau as symbolic variable instead of an actual, positive number.
As for your follow on question, don't use symsum(). Just use regular sum().
syms tau1 tau2 positive
f(t) = sum(exp(-t./[tau1 tau2]))*heaviside(t)
f(t) = 
fourier(f(t),t,w)
ans = 
Can use actual values for tau1 and tau2 if you have them.
Voss
Voss 2022 年 7 月 11 日
"where N is the end of the series doesn't seem quite right, since the sum is over [tau_i]"
If N is the length of tau, then that seems ok to me.
Summing the signals using a vector tau:
syms t real
tau = [1 2 0.5 0.2 0.1];
z = sum(exp(-t./tau))*heaviside(t)
z = 
L'O.G.
L'O.G. 2022 年 7 月 11 日
@Paul @Voss Thank you both very much.
Voss
Voss 2022 年 7 月 11 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2021b

質問済み:

2022 年 7 月 10 日

コメント済み:

2022 年 7 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by