Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Fourier coefficients

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32960] Re: Fourier coefficients
  • From: "Mariusz Jankowski" <mjkcc at usm.maine.edu>
  • Date: Thu, 21 Feb 2002 02:07:19 -0500 (EST)
  • References: <a4vgbf$r39$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Phil McGlone" <phil at icu.strath.ac.uk> wrote in message
news:a4vgbf$r39$1 at smc.vnet.net...
>
> I am trying to do something really "simple".  I want to Plot the Fourier
> coefficients as vertical lines.  The line height should be proportional
> to the magnitude of its respective coefficient.  I just can't seem to
> get it though.  Any ideas?
>

Phil, download my SignalPlot package from
http://www.ee.usm.maine.edu/ftp/pub/mathematica/ . It includes the function
LinePlot which plots lists as vertical lines with "bubbles" as in most ee
texts.

Also, here is an example with a simplified implementation:


Here is some data.

In[1]:=
x = {1, 1, 1, 1, 0, 0, 0, 0};

Now calculate the magnitudes of the Fourier coefficients.

In[3]:=
X = Abs[Fourier[x]]

Out[3]=
{1.4142135623730951, 0.9238795325112867, 0.,
  0.38268343236508984, 0., 0.38268343236508984, 0.,
  0.9238795325112867}

Each value must now be used to define a Line graphics element. First combine
each magnitude with its corresponding x value.

In[5]:=
data = Transpose[{Range[Length[X]] - 1., X}]

Out[5]=
{{0., 1.4142135623730951}, {1., 0.9238795325112867},
  {2., 0.}, {3., 0.38268343236508984}, {4., 0.},
  {5., 0.38268343236508984}, {6., 0.},
  {7., 0.9238795325112867}}

Convert to a list of Line primitives.

In[7]:=
lines = (Line[{{#1[[1]], 0.}, {#1[[1]], #1[[2]]}}] & ) /@ data

Out[7]=
{Line[{{0., 0.}, {0., 1.4142135623730951}}],
  Line[{{1., 0.}, {1., 0.9238795325112867}}],
  Line[{{2., 0.}, {2., 0.}}],
  Line[{{3., 0.}, {3., 0.38268343236508984}}],
  Line[{{4., 0.}, {4., 0.}}],
  Line[{{5., 0.}, {5., 0.38268343236508984}}],
  Line[{{6., 0.}, {6., 0.}}],
  Line[{{7., 0.}, {7., 0.9238795325112867}}]}

Display.

Show[Graphics[lines, Axes->True]]



  • Prev by Date: RE: coloured contour plots
  • Next by Date: Re: Numerical Differentiation using Fourier Transform
  • Previous by thread: Re: Fourier coefficients
  • Next by thread: coloured contour plots