MathGroup Archive 2007

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

Search the Archive

Re: graphing frequency & amplitude?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79208] Re: [mg79153] graphing frequency & amplitude?
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Sat, 21 Jul 2007 04:23:38 -0400 (EDT)
  • References: <200707200716.DAA23358@smc.vnet.net>

On Jul 20, 2007, at 3:16 AM, efifer at fas.harvard.edu wrote:

> Hi,
>
> I am trying to create a graph that graphs frequency versus  
> amplitude of a sound
> made by the sum of two sine waves. I tried fourier transforming  
> them and
> graphing it, yet it looks to me like the graph is plotting time  
> rather than
> frequency. How do I change this?
>
> Plot[10*Sin[200t] + 10*Sin[100t], {t, 0, 1}]
>
> data = Table[10*Sin[200t] + 10*Sin[100t], {t, 0, 100}]
>
> ListPlot[Abs[Fourier[data]], PlotJoined -> True, PlotRange -> All]

This is a graph of the power spectrum, but you have to remember that  
the 0 frequency is in the first position of the result from Fourier.   
Rotate the list before plotting to get things to line up.  However  
your sample rate is too small, so your spectrum is aliased, the  
frequencies of your two signals are 100/(2 Pi) and 200/(2 Pi) which  
are about 16 and 32 Hertz respectively.  Your sample rate is 1Hz.   
Here's an example of the power spectrum of two sine waves with  
frequencies 0.125 and 0.25 Hertz sampled at 1 Hertz.

data=Table[Sin[2 Pi 0.125 t]+Sin[2 Pi 0.25 t],{t,0,127}];

ListPlot[Abs[RotateRight[Fourier[data],Quotient[Length[data], 
2]]],PlotJoined->True,PlotRange->All]

Regards,

Ssezi


  • Prev by Date: Re: Mathematica to .NET compiler
  • Next by Date: Re: Mirror images of a font...
  • Previous by thread: graphing frequency & amplitude?
  • Next by thread: Re: graphing frequency & amplitude?