3

I would like to know how to plot the Dirac Delta result of the Fourier transform of the following typical expression

tf = FourierTransform[(A Sin[ω1 t]) + (A2 Sin[ω2 t]), 
      t, ω, FourierParameters -> {1, -1}] // TraditionalForm
Karsten7
  • 27,448
  • 5
  • 73
  • 134
diego
  • 31
  • 1
  • 3
  • 3
    You can't plot delta functions because they have "support of measure zero." It's not clear what you really want. Do you want to plot a vertical line at the location of each discrete frequency? – Jens Jun 26 '16 at 17:52
  • I want to plot the spectrum of the sum of two sine signals – diego Jun 26 '16 at 22:03

3 Answers3

5

You can replace the delta functions with something you can plot, to get some sort of visualisation. E.g.

Block[{A = 1, A2 = 1.4, ω1 = 40, ω2 = -30, 
  DiracDelta = UnitTriangle}, Plot[Abs[tf], {ω, -50, 50}]]
Karsten7
  • 27,448
  • 5
  • 73
  • 134
mikado
  • 16,741
  • 2
  • 20
  • 54
5

If your "typical expression" is a discrete sum of sine waves, then we might treat the delta function as the "unit" of the vertical axis and plot the magnitude of the coefficients.

Block[{A = 1, A2 = 1.4, ω1 = 40., ω2 = Sqrt@40.},
 freqs = Cases[tf, DiracDelta[f_] :> Root[f, 1], Infinity];
 DiscretePlot[
  Abs[tf] /. DiracDelta -> DiscreteDelta,
  {ω, freqs},
  AxesOrigin -> {0, 0}]
]

Mathematica graphics

On the other hand, if there's a continuous spectrum, use Plot:

tf = FourierTransform[
   Exp[-t^2] (A Sin[ω1 t] + A2 Sin[ω2 t]), t, ω, 
   FourierParameters -> {1, -1}];
Block[{A = 1, A2 = 7/5, ω1 = 4, ω2 = Sqrt@2},
 Plot[Abs[tf], {ω, -8, 8}, WorkingPrecision -> 50]]

Mathematica graphics

Michael E2
  • 235,386
  • 17
  • 334
  • 747
4

I think there are two different aspects here. First let add to sin signals, say, $\sin[(\omega+\Delta)t]$ and $\sin[(\omega-\Delta)t]$

Manipulate[ Plot[Sin[2 Pi (n + d) x] + Sin[2 Pi (n - d) x], {x, -5 Pi, 5 Pi}],
{n, 1, 10}, {d, 0, 1}]

enter image description here

As you can see the difference in frequency will give you beats. Now let say you want to create a Delta function like spectrum you have to add infinite number of Sin waves with proper weight. I choose here a gaussian weight. I choose Cos to make things symmetric.

Manipulate[Plot[Sum[Exp[-k^2 d^2] Cos[k x], {k, 0, 10, 0.1}], {x, -5 Pi, 5 Pi}, 
PlotRange -> All], {d, 0, 1}]

enter image description here

As you can see by controlling the gaussian width of distribution you can get a nice and sharp spike. For a true Dirac-Delta function you have to take the integration limit for k to infinity.

Sumit
  • 15,912
  • 2
  • 31
  • 73