MathGroup Archive 1998

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

Search the Archive

Re: Attach frequency list to a list of fourier tranformed numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14696] Re: Attach frequency list to a list of fourier tranformed numbers
  • From: "Peltio" <peltioNOS at PAMyahoo.com>
  • Date: Sun, 8 Nov 1998 21:15:53 -0500
  • Organization: Peltio Inc.
  • References: <720rsl$1sn@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi, Raymond

Your question:
How do I attach the actual frequency values to a list of numbers
transformed using the Fourier[list] command?

My answer:

Here's  what I do.
Actually the answer depends on what the initial data mean. Let's suppose
we're in time domain, and that you have sampled a waveform over an
interval T with sampling time Ts, that is you have the values at t=
0,Ts,2Ts,...,kTs,..(n-1)Ts. (henceTs=T/n) The frequencies associated
are f=1/T and fmax=1/Ts. Your Fourier transformed data will span an
interval fmax wide with step f. But, beware!, your spectrum is folded,
so you will go with the "real" values from frequency 0 to frequency
fnyq=fmax/2 and from then on (fnyq to fmax) you'll have a folded copy
of the first part.
To associate the frequencies to the spectrum we need to know either the
sampling time Ts or the interval duration T, but let's start with the
continuous signal of frquency 2 Hz

    f[t_]:=Sin[ 2Pi 2t ]
    data=Table[ { t , f[t]+0.Random[Real,{-.5,.5}]},   {t,0,5,5/255} ];
    Length[data]
        Out[1]=256
(incidentally, powers of two are what Fourier crunching motors do
expect)

Let's scorporate time values from signal values

    trange=#[[1]]&/@data; signal=#[[2]]&/@data;


the interval duration and the sampling interval are

    T=(Max[trange]-Min[trange])// N ; Ts=T/Length[trange//N ;


frequency will vary from 0 to 1/Ts in 256 steps 1/T wide

    frange=Range[0,1/Ts-1/T,1/T];
    Length[frange]
        Out[48]=256


Now we calculate the Fourier transform of the 256 point data

    transform=Fourier[signal]/Sqrt[Length[signal]]//Chop;
    Length[transform]
        Out[49]=256


and finally we put the frequency data together

    modulo=Transpose[{frange,Abs[transform]}];

Try this to see that indeed your spectrum shows two peaks at 2Hz and at
49.2 (that is 51.2-2) Hx.
The value at 51.2 is 1/Ts, while 2 is the frequency of the sinusoid we
used to build our data set


    ListPlot[modulo,PlotRange->All,PlotJoined->True]

    Show[%,PlotRange->{{0,10},All}]

In case you prefer it you can even unfold your spectrum so to show the
components at negative frequencies, spanning from -fnyq to +fnyq. But
at this point it's quite straightforward.

What worries me is that to do this in general, *I think*, you'll have to
discern between the case with an even number of points and an odd
number, and worst still you need to know wether frequency 0 is
comprised in the data set or not (-1,0,1,...  or -1.5,-0.5,0.5,1.5,..).
So I, too, have a question for the newsgroup: is there a simple and
straigthforward method to unfold the spectrum regardless of this
matter?

Hope that helps.
Regards,
Peltio



  • Prev by Date: Re: Differentiation ?
  • Next by Date: Re: Single character in Italics. Ervin Doyle;
  • Previous by thread: Attach frequency list to a list of fourier tranformed numbers
  • Next by thread: Re: Attach frequency list to a list of fourier tranformed numbers