# Plotting amplitude spectra of modulated message signal

I'm trying to plot the amplitude spectrum of the modulated message signal,

I have managed to plot it by working through the maths, expanding out each trig function, and then drawing onto a graph with the below code

Plot[f, {f, 0, 1200}, PlotStyle -> None,
PlotRange -> {0, 4},(*just gives the axes*)

Epilog -> { (*amplitude lines*)

Line[{{1000, 0}, {1000, 3}}], (*carrier*)
Line[{{1010, 0}, {1010, 1.5}}], Line[{{990, 0}, {990, 1.5}}],
Line[{{1030, 0}, {1030, 1}}], Line[{{970, 0}, {970, 1}}],
Line[{{1050, 0}, {1050, 0.5}}], Line[{{950, 0}, {950, 0.5}}]
}]


Which gives the desired plot,

I was wondering however, if there is an easier way to plot the amplitude spectrum from the equation?

To make it clearer, the x-axis is the half the frequency inside the trig function (eg. 2000\pi.t is 1000 on the x-axis) and the y is the coefficient of the trig function (ie. 3cos is 3 on the y-axis).

• Your amplitude modulator is $3 \cos [20 \pi t + \pi/4]]...$. Why not simply plot that? – David G. Stork Apr 8 '16 at 20:21
• Fourier . . ? – BlacKow Apr 8 '16 at 20:21
• @DavidG.Stork he seems to want spectrum, i.e. frequency in x- axis – BlacKow Apr 8 '16 at 20:23
• just plotting the 3Cos... gives the waveform of the modulated message, dropbox.com/s/wwr60w5geliyfqn/test.png?dl=0 I want the amplitude spectra of this modulated waveform (as @BlacKow commented) – FlamingSquirrel Apr 8 '16 at 20:26
• the message signal, 3cos(20pi t + pi/4) + 2sin(60pi t) - cos(100pi t). Sorry i just subbed that into the equation at the top without telling you! – FlamingSquirrel Apr 8 '16 at 20:51

I was too lazy to figure out your normalization, so I wrote down formulae for Fourier series.

f[t_] := 3 Cos[2000 Pi t] +
0.5 Cos[2000 Pi t] (3 Cos[20 Pi t + Pi/4] + 2 Sin [60 Pi t] -
Cos[100 Pi t]);
pl = {#, 1/(Pi) Abs@Integrate[f[t/Pi] E^-(I 2 # t), {t, -Pi, Pi}]} & /@
Range[900, 1100, 10];
ListPlot[#, Filling -> Axis, PlotRange -> Full ] &@pl


• That works! It seems my Mathematical expansion was a bit out! – FlamingSquirrel Apr 8 '16 at 21:24
• Where did you get the Abs@Integrate.... Stuff from? – FlamingSquirrel Apr 8 '16 at 21:55
• @FlamingSquirrel It's pretty much definition of Fourier coefficient. You can use FourierCoefficient but I encountered weird performance issue. – BlacKow Apr 8 '16 at 21:58
• Okeydokey! Thank you for the solution. Will give FourierCoefficients a go myself - see what the performance issue is – FlamingSquirrel Apr 8 '16 at 22:00
• @FlamingSquirrel issue – BlacKow Apr 8 '16 at 22:01
f[om_] = FourierTransform[
Cos[2000 Pi t] (3 + 1/2 (3 Cos[20 Pi t + Pi/4] + 2 Sin[60 Pi t] -
Cos[100 Pi t])), t, om]


The following transforms the above formula in graphics primitives Line[...] :

 ti00 = Collect[f[om], DiracDelta[_], coeff];
ti01 = ti00 /.
coeff[c_] DiracDelta[s_] :>
With[{om3 = om /. Last[Solve[s == 0, {om}]]},
Line[{{om3/(2 Pi), 0}, {om3/(2 Pi), Abs[c]}}]];

Graphics[List @@ ti01, AspectRatio -> 0.2, Frame -> True,
PlotRange -> {{0, 1200}, {0, 5}}, ImageSize -> 600,
AxesOrigin -> {0, 0}]


The negative frequencies are not shown.