1
$\begingroup$

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

enter image description here

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,

enter image description here

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).

$\endgroup$
  • $\begingroup$ Your amplitude modulator is $3 \cos [20 \pi t + \pi/4]]...$. Why not simply plot that? $\endgroup$ – David G. Stork Apr 8 '16 at 20:21
  • $\begingroup$ Fourier . . ? $\endgroup$ – BlacKow Apr 8 '16 at 20:21
  • $\begingroup$ @DavidG.Stork he seems to want spectrum, i.e. frequency in x- axis $\endgroup$ – BlacKow Apr 8 '16 at 20:23
  • $\begingroup$ 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) $\endgroup$ – FlamingSquirrel Apr 8 '16 at 20:26
  • $\begingroup$ 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! $\endgroup$ – FlamingSquirrel Apr 8 '16 at 20:51
2
$\begingroup$

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

enter image description here

$\endgroup$
  • $\begingroup$ That works! It seems my Mathematical expansion was a bit out! $\endgroup$ – FlamingSquirrel Apr 8 '16 at 21:24
  • $\begingroup$ Where did you get the Abs@Integrate.... Stuff from? $\endgroup$ – FlamingSquirrel Apr 8 '16 at 21:55
  • $\begingroup$ @FlamingSquirrel It's pretty much definition of Fourier coefficient. You can use FourierCoefficient but I encountered weird performance issue. $\endgroup$ – BlacKow Apr 8 '16 at 21:58
  • $\begingroup$ Okeydokey! Thank you for the solution. Will give FourierCoefficients a go myself - see what the performance issue is $\endgroup$ – FlamingSquirrel Apr 8 '16 at 22:00
  • 1
    $\begingroup$ @FlamingSquirrel issue $\endgroup$ – BlacKow Apr 8 '16 at 22:01
4
$\begingroup$
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]

enter image description here

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}]

enter image description here

The negative frequencies are not shown.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.