0
$\begingroup$

When I create a list of discrete measurements of a sine wave and then use Fourier[] to transform it, I get a peak on the frequency axis that is characteristically less than the measured frequency and less by more than a bin-width. It may be my misunderstanding what Fourier is doing. Or it may be a mistake in my test code. Any help would be appreciated.

freq = 102; t[\[Theta]_] := \[Theta]/(freq 2 Pi)
tbl = Table[{t[ \[Theta]], Sin[\[Theta]]}, {\[Theta], 0, 5 (2 Pi),  
    Pi/500}];
fourier = Fourier[N[tbl[[All, 2]], 24]];
(Range[Length[tbl]] freq/Length[tbl])[[Max[
    Position[Abs[fourier], Max[Abs[fourier]]]]]] // N

ListPlot[tbl,
 PlotRange -> {{0, .051}, All}, AxesLabel -> {"s", ""}, 
 PlotLabel -> Row[{"\[Omega] = ", Quantity[freq, "Hertz"]}]]

ListPlot[
 Join[{{0, 0}}, 
  Transpose[{(Range[Length[tbl]] freq/Length[tbl])[[2 ;; -1]], 
    Abs[fourier][[2 ;; -1]]}]],
 PlotRange -> {(*{1/2,110}*){101.5, 102.5}, All}, 
 AxesLabel -> {"Hz", ""},
 PlotLabel -> "Fourier Spectrum", Joined -> True]

Clear[t, tbl, fourier, freq]
$\endgroup$
3
  • 2
    $\begingroup$ I have put some comments on Fourier here that may help you. $\endgroup$
    – Hugh
    Commented Nov 7 at 7:37
  • $\begingroup$ Thanks, Hugh. The explanation there was helpful. It focused my hazy understanding. I'm still confused though. I think my experiment as written has a sampling rate of 102000 measurements/second. So by your point no. 7, my Fourier list should have frequencies from zero to almost 102000 Hz. But my plot of frequencies stops at 102 Hz and doesn't change even if I change the code shown to increase sampling rate 10 fold. $\endgroup$
    – crabtree
    Commented Nov 7 at 23:03
  • $\begingroup$ I think you have fallen into the common trap of aliasing. Your sine wave is at 102 cycles per second. Your sampling is at 500/Pi = 159.155 measurements per second. With this sample rate you obtain one and a fraction of points per cycle. You need a sample rate of 204 measurements per second to get just two points per cycle. See Nyquist sampling theorem. You must sample at a rate much higher than the frequency you are interested in. Note also that you only have 5001 points in your time history. Not what you wanted. $\endgroup$
    – Hugh
    Commented Nov 8 at 8:46

0

Browse other questions tagged or ask your own question.