I'm trying use Mathematica to compute the Discrete Fourier Transform (DFT) of a table of data points and then plot the result. As a test run, I took values from the function $x=f(t)=\sin(2\pi t) $ for $0\leq t \leq 2$ in increments of $\Delta t=1/32=0.03125$. Here is the code I put in Mathematica:
tval = Table[i, {i, 0, 2, 0.03125}]
xval = Table[Sin[2*Pi*i], {i, 0, 2, 0.03125}]
data = Transpose[{tval, xval}]
ListLinePlot[data, PlotRange -> All]
ListLinePlot[Abs[Fourier[data]], PlotRange -> All]
Here is the plot of data
from the line ListLinePlot[data, PlotRange -> All]
:
However, I get a weird looking plot for ListLinePlot[Abs[Fourier[data]], PlotRange -> All]
:
I would expect to have a peak in the frequency domain at 1 Hz, since $f(t)$ is a sine wave with frequency 1 Hz. However, the second plot above doesn't peak at 1 Hz and the end of the plot goes up for some reason.
Am I doing something wrong? I have heard a little bit about "aliasing" when using the DFT, but I'm not sure if that is the case here, or what I could do about it if it was. Please keep in mind that I am pretty new to the concept of the Fourier Transform.
Fourier
here with examples. JM has given you the correct answer you should not include time when usingFourier
. $\endgroup$