# Discrete Fourier Transform with x axis data?

Usually, Fourier Transform in mathematica is supplied by y data only, like the famous Sin[x] transform example. What if my data is a list of {x,Sin[x]}? and x has units (for example, nm)? I would expect to see a spectrum with the correct units as frequencies. How can I achieve this?

Data1 = Table[Sin[x], {x, 0, 2*Pi, 2*Pi/1000}];
ListPlot[Abs[Fourier[Data1]], PlotRange -> All, Joined -> True]


and you see the plot doesn't make much sense. Although i have 2 peaks, their frequencies are not specified. I actually couldn't know which is + frequency and which is - frequency. In deed, i can not make much sense of this plot except for it has peaks.

Data2 = Table[{x, Sin[x]}, {x, 0, 2*Pi, 2*Pi/1000}];
ListPlot[Abs[Fourier[Data2]], PlotRange -> All, Joined -> True]


I would expect this to recover the x-axis information. But it doesn't . So what should I do if I wanted to know, for example, the peaks in the plot has a meaningful x axis, corresponding to , 2\Pi for example

Thanks

• See the Frequency identification example on the Fourier[] doc page – Dr. belisarius Dec 18 '14 at 21:42
• I didn't find it helpful.. And still it can not transform with real data (ones having x axis) – bboczeng Dec 18 '14 at 21:56
• to compare, origin labs can handle it extremely well. – bboczeng Dec 18 '14 at 21:57
• You might find the answer here useful to understand what the DFT is doing. mathematica.stackexchange.com/q/33574/1783 – bill s Dec 18 '14 at 21:58
• Is this any improvement? Fourier[data1, FourierParameters -> {0, 2*Pi/1000}] – Daniel Lichtblau Dec 18 '14 at 22:03

If you look up ListPlot you will see that it uses point number for the x - axis. You have to make the frequency axis. Your question is a little muddled because you talk about time and frequency but the units you suggest are nm which I take to be nano meters. If you are working with length in one domain then when transformed you are in units of reciprocal length or wave number. I will continue with time to frequency transformation. The increment in the frequency domain is given by the sample rate divided by the number of points. The sample rate is the reciprocal of the time step. The frequency spectrum starts at zero and continues to the sample rate less one increment. Here is one way to make your frequency axis.

sr = 1000./(2 Pi);  (* sample rate*)
inc = sr/Length[Data1]; (* increment *)
freq = Table[f, {f, 0, sr - inc, inc}];


Now you can plot your data

ListPlot[Transpose[{freq, Abs[Fourier[Data1]]}], PlotRange -> All,
Joined -> True]


Your sample rate is small compared to the frequency so your data is concentrated near the origin. Expanding the plot shows that your peak is at the second point.

ListPlot[Transpose[{freq, Abs[Fourier[Data1]]}],
PlotRange -> {{0, 1}, All}, Joined -> True]


I suggest you write a Module if you whish to calculate the frequency axis automatically.