Skip to main content
1 of 4
xslittlegrass
  • 27.8k
  • 9
  • 102
  • 187

Why does Fourier give a shifted frequency?

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using signal processing?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency (eV)", "Fourier transform (arb.)"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

xslittlegrass
  • 27.8k
  • 9
  • 102
  • 187