Thread: Plotting Dirac delta function in Mathematica.

1. Plotting Dirac delta function in Mathematica.

Hello,

I'm trying to check my work, but having problems with plotting in Mathematica... Until now i just used Heaviside[ ] function and did ok... but I can't get to plot Dirac... i tried to do it and just can't... please someone help

I'm trying to plot these signals....

$h(t) = \delta u (t+2) + 2\delta u(t+1)$

and

$h(t) = \delta u(t-1) -\delta (t-3)$

2. Originally Posted by sedam7
Hello,

I'm trying to check my work, but having problems with plotting in Mathematica... Until now i just used Heaviside[ ] function and did ok... but I can't get to plot Dirac... i tried to do it and just can't... please someone help

I'm trying to plot these signals....

$h(t) = \delta u (t+2) + 2\delta u(t+1)$

and

$h(t) = \delta u(t-1) -\delta (t-3)$
What do you expect the plot to look like? You do know what the Dirac delta is?

CB

3. Note that in Mathematica,

$\delta(x)\leftrightarrow\text{DiracDelta}[x].$

4. Originally Posted by Ackbeet
Note that in Mathematica,

$\delta(x)\leftrightarrow\text{DiracDelta}[x].$
But how will M. plot that (if at all), an upward pointing arrow at x=0? Wolfram Alpha certainly does not want to plot it!

CB

5. Mathematica just shows the axes. There's no line or arrow or anything. Here's a method for plotting the DiracDelta as an arrow:

<<GraphicsArrow
PlotOne=Plot[DiracDelta[x-1],{x,0,2}]
PlotTwo=Show[Graphics[Arrow[{1,0},{1,1}]]]
Show[PlotOne,PlotTwo]

That will give you an arrow going from the point <1,0> to the point <1,1>, representing the delta function $\delta(x-1),$ of "strength" 1.

If you wanted to generalize, you could let

MyDiracDelta[Strength_,a_]=Arrow[{a,0},{a,Strength}]

after loading the arrow package as shown above.

Then you could do

PlotOne=Plot[Strength DiracDelta[x-a],{x,a-1,a+1}]
PlotTwo=Show[Graphics[MyDiracDelta[Strength,a]]]
Show[PlotOne,PlotTwo]

and so on.

Hope that helps.