2
$\begingroup$

I'm trying to do a Fourier Transform of the following Data, but I'm completely stuck.

Here's what I've done so far:

data = Drop[data, 1];
dat = data /. {x_, y_, z_, w_} -> {x + y/12., 10 z};
ListLinePlot[Abs[Fourier[dat]], PlotRange -> {Automatic, {0, 40}}]

I don't understand why it keeps displaying this weird plot enter image description here

Anyone have any clue what I'm doing wrong? I'm just learning this Fourier thing so I'm real lost.

$\endgroup$
1
  • 1
    $\begingroup$ Try ListPlot[Abs[Fourier[dat]], PlotRange -> {Automatic, {0, 350}}] Result $\endgroup$ Mar 12, 2014 at 2:47

1 Answer 1

5
$\begingroup$

Fourier does not accept a list of {time, sample} pairs - if you give it a 2D list it will do a 2D transform. Therefore you need to use Fourier on just the list of samples. To get the correct frequency scale on the plot you can use DataRange.

data = Import["http://solarscience.msfc.nasa.gov/greenwch/spot_num.txt", "Table"];

dat = Rest[data] /. {x_, y_, z_, _} :> {x + y/12., 10 z};

n = Length[dat];
t = dat[[2, 1]] - dat[[1, 1]];
fourierdata = Abs @ Fourier[dat[[All, 2]]];

ListLinePlot[fourierdata[[;; 1 + n/2]],
 DataRange -> {0, 1/(2 t)},
 PlotRange -> {{0, 0.5}, {0, 10000}}]

enter image description here

$\endgroup$
1
  • $\begingroup$ +1 I can't figure out how I was able to avoid seeing DateRange in the docs. $\endgroup$ Mar 12, 2014 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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