I am wondering what is the correct function in Mathematica to plot the true impulse function, better known as the DiracDelta[]
function. When using this inside of a function or just the function itself when plotting, it renders output = zero. Quick example:
Plot[DiracDelta[x], {x,-1,1}]
I am wondering, is this the correct delta function which is infinite in height at zero and zero everywhere else. I have seen other functions such as KroneckerDelta[]
, but this seems to do the same exact thing. The code is below:
eqn1wb := (2 ((I Pi f) Exp[(-I) 2 Pi f]) ((1/2) DiracDelta[f-2] +
DiracDelta[f+2]))/(1 + I 2 Pi f);
wb1 = Plot[Re[eqn1wb], {f, -5, 5},
PlotRange :> All, PlotStyle :> {Thick, Red},
AspectRatio :> 1,
GridLines :> {{-4, -2, 2, 4}, {1.0, 0.5, -0.5, -1.0}},
PlotLabel :> "Re(w) - Frequency Response",
AxesLabel :> {"f", "W(f)"}
]
Answer
To create the plot you could replace any occurrence of DiracDelta[a]
with something like 10000 UnitStep[1/10000 - a^2]]
, so for example to plot
f[x_] := DiracDelta[x - 2] + DiracDelta[x + 2]
you could do something like
Plot[Evaluate[f[x] /. DiracDelta[a_] :> 10000 UnitStep[1/10000 - a^2]],
{x, -4, 4}, Exclusions -> None, PlotPoints -> 800]
Note that for Mathematica to see the discontinuities you need to increase the number of plot points. The number of points needed will depend on the plot range, so you might have to tweak that.
Comments
Post a Comment