Here's what I want to do, initially at least: I have an oscillator, it's in some force field, I've integrated it using the Euler method, so I have a list of points of the form {t,x}, where t is the time and x is its position. Here it is, plotted:
Now (before I do more complicated stuff), I want to get the Fourier transform, which at this point ideally should be basically just a Dirac Delta function right around the fundamental frequency of ~7.95, right? Just by eye, the function is pretty clearly a single frequency.
However, Fourier[] doesn't take a list of pairs of the form I said, only single values. So I do:
vals = myList[[All,2]];
And then I can do Fourier on it, like the example from the documentation:
ft = Abs[Fourier[vals]];
Print@ListLogPlot[ft, PlotRange -> {{0, 100}, {0, .5}}];
Print@ListLogPlot[ft, PlotRange -> All];
Which gives me:
So there are two main problems for me here. The first is that, as you can see in the first plot, there is a peak (I assume at the fundamental frequency), but the actual number is wrong. I assume this is because I basically stripped my data of any information about the time to put it in the form accepted by Fourier[], which I guess basically just assumes the "independent variable" of your data is their integer indices. So I'd like to have it graph it in the form where it'll show the peak at the original frequency. I tried "scaling" it, assuming that if my data before ranged from 0 to 10, and had 10,000 values, so that Fourier was calculating it with the length scale {0,10000}, then any frequency Fourier returned would actually be 10000/10=1000 times smaller than the actual frequency, so I could just plot
Table[{1000*i,ft[[i]]},{i,Length@ft}]
to get what I want, but this didn't work.
My second problem is visible in the second graph, that aside from the peak near ~20 (from the first graph), it starts diverging for large numbers too. Why's this happening?
Thanks!
edit: From looking at a few threads it seems like people not sampling enough (lower than the Nyquist frequency) seems to be a a common problem, but I don't think it is here, in the example that produced those images, I have:
A period is 0.125664
deltat = 0.000251327
So I'm sampling many times in each period.