1D DFT: Example #2: DC + sum of cosines

Sampled sequence: 2 + cos(2π t) + 2 cos(4π t)

x[t_] := 2 + Cos[2π t] + 2 Cos[4π t] ; xd = Sampler[x, fs = 10, {0, 4}] ; If[OddQ[Le ... e, FrameTrue, Axes {True, False}, ImageSize500, AspectRatio1/3] ;

[Graphics:../HTMLFiles/index_16.gif]

View as "image"

ShowImage[{Last /@ xd}, Round[500/Length[xd]], 6, 0] ;

[Graphics:../HTMLFiles/index_18.gif]

Magnitude plot of DFT as a function of index k

fft = DFT[xd] ; g3 = DiscreteListPlot[{#[[1]], Abs[#[[2]]]} & /@ fft, Red, PlotRangeAll, FrameTrue, AxesFalse, AspectRatio1/3, ImageSize500] ;

[Graphics:../HTMLFiles/index_20.gif]

View as "image"

tmp = Log[1 + Abs[Last /@ fft]] ; RowBox[{RowBox[{ShowImage, [, RowBox[{{tmp}, ,, Round[500/Length[tmp]], ,, RowBox[{1.2, Max[tmp]}]}], ]}], ;}]

[Graphics:../HTMLFiles/index_22.gif]

Phase plot of DFT as a function of index k

fft = DFT[xd] ; RowBox[{RowBox[{g4, =, RowBox[{DiscreteListPlot, [, RowBox[{RowBox[{RowBox[{Ro ... , ,,  , AxesFalse, ,,  , AspectRatio1/3, ,,  , ImageSize500}], ]}]}], ;}]

[Graphics:../HTMLFiles/index_24.gif]

Rearrange magnitude plot of DFT as a function of frequency f

g5 = DiscreteListPlot[FourierRearrange[Abs[Last /@ fft], fs], Red, PlotRangeAll, FrameTrue, AxesFalse, AspectRatio1/3, ImageSize500] ;

[Graphics:../HTMLFiles/index_26.gif]

View as "image"

tmp = Log[1 + (Last /@ FourierRearrange[Abs[Last /@ fft], fs])] ; ShowImage[{tmp}, Round[500/Length[tmp]], Max[tmp]] ;

[Graphics:../HTMLFiles/index_28.gif]


Created by Mathematica  (February 5, 2004)