0
$\begingroup$

The following simple function has clearly three frequency components:

 fun[x_] = Cos[ x] + Cos[2 x] + Cos[3 x];
data = Table[fun[x], {x, 0, 2 \[Pi], 0.1}];
ListPlot[data, ImageSize -> 200]

How can one show these frequencies using the Fourier transform? I tried the following

ListLinePlot[Abs[Fourier[data]], PlotRange -> All, ImageSize -> 200]

But it doesn't seem to lead to the proper answer.

Edit: I would expect the Fourier plot to show three peaks corresponding to three frequencies in the ratio 1:2:3.

$\endgroup$
  • $\begingroup$ Try ListPlot instead of ListLinePlot and you'll see the both frequencies! $\endgroup$ – Ulrich Neumann Sep 18 at 9:39
  • $\begingroup$ @UlrichNeumann, thanks. With two frequencies, it was looking suspicious to me. Now with three frequencies, it is still showing two peaks with ListPlot. $\endgroup$ – Patrick Sep 18 at 10:00
  • $\begingroup$ I have put some basic information on Fourier here which may help. Your three frequencies are a perfect match to your time interval and are multiples of the fundamental frequency so you get the first three points in the spectrum. $\endgroup$ – Hugh Oct 18 at 16:50
1
$\begingroup$

ListPlotshows the frequencies:

fun[x_] = Cos[ x] + Cos[2 x] + Cos[3 x];
data = Table[fun[x], {x, 0, 2 \[Pi], 0.1}];
ListPlot[Abs[Fourier[data]], PlotRange -> All]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks. Shouldn't there be three peaks? $\endgroup$ – Patrick Sep 18 at 10:06
  • $\begingroup$ Yes, every point stands for a peak of the special frequency. $\endgroup$ – Ulrich Neumann Sep 18 at 10:11
  • $\begingroup$ Then there are six frequencies depicted in this plot? $\endgroup$ – Patrick Sep 18 at 10:15
  • 2
    $\begingroup$ @Patrick No there are only three frequencies for your signal. More details you might find in Nyquist–Shannon sampling theorem $\endgroup$ – Ulrich Neumann Sep 18 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.