If condition inside integration
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dharma Khatiwada
il 30 Ott 2021
Commentato: Walter Roberson
il 31 Ott 2021
Hi,
I am trying to keep if condition inside integration of exponential function and solve the integral in Matlab. c(x) is 4 at x =1, 4, 7, 10, 13 otherwise zero. Any help would be appreciated.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/783968/image.png)
0 Commenti
Risposta accettata
Walter Roberson
il 30 Ott 2021
I am pretty sure you do not want that definition of c(x)
syms x t
c(x) = piecewise(x == 1 | x == 4 | x == 7 | x == 10 | x == 13, 4, 0)
inner = c(x) * exp(-2*(t-x))
y(t) = simplify(int(inner, x, 0, t))
string(y)
fplot(y, [-20 20])
This happens because your c(x) definition is discontinuous, and the width of the event x == 4 (or each of the other values) is 0, so the integral at those points is 0.
Compare:
c2(x) = (dirac(x-1) + dirac(x-4) + dirac(x-7) + dirac(x-10) + dirac(x-13)) * 4
inner2 = c2(x) * exp(-2*(t-x));
y2(t) = simplify(int(inner2, x, 0, t))
string(y2)
fplot(y2, [-20 20])
This defines c(x) in terms of a distribution rather than in terms of points, giving meaning to the integral at those values.
6 Commenti
Walter Roberson
il 31 Ott 2021
dirac(0)
syms x
int(dirac(x), x, -1, 1)
The Dirac Delta is not really a function. dirac(0) is not really inf . dirac() is defined such that the integral across 0 is 1. So what happens with int() of dirac is correct, and the Inf is not really correct.
There are different ways of defining Dirac. One of the ways is as the limit of a rectangle n units high and 1/n wide, as n approaches infinity: the area is fixed, but as the width approaches 0, the height approaches infinity. Saying that it is infinity such as dirac(0) shows, is a short-hand that is not really true.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!