testData = Table[N@Sin[500 x], {x, 0, 100}];
ListLinePlot[Abs[Fourier[testData]], PlotRange -> Full]
Gives me
Which I do not expect because the Fourier Transform is FourierTransform[Sin[500 x], x, f],
I Sqrt[Pi/2] DiracDelta[-500+f]-I Sqrt[Pi/2] DiracDelta[500+f]
I'm not saying that Mathematica's Fourier function is somehow faulty. But could someone please explain why there isn't a peak around 500? This is the frequency of the signal after all...
Answer
As mentioned by @Rahul, you have not sampled your sine wave often enough and have introduced artifacts due to aliasing. The frequency of Sin[500 x]=Sin[2 Pi f x]
is $f=500/(2\pi)$, which is about 80 Hz. At least two samples per cycle are required to avoid aliasing, hence the default $x$ interval of 1 in {x,0,100}
must be reduced to less than about $1/(2*80)=0.006$.
In addition, the discrete fast Fourier transform assumes periodicity. Hence, care must be taken to match endpoints precisely. An interval without an exact integral multiple of the sine wavelengths will return blurred Dirac delta functions.
I set the sampling interval to $(1/f)/4$, which is small enough to avoid aliasing. There are an integral number of wavelengths, 100*(2 Pi/500)/4, and the endpoints are matched.
testData = Table[N@Sin[500 x],
{x, 0, 100*(2 Pi/500)/4 - (2 Pi/500)/4, (2 Pi/500)/4}];
ListLinePlot[Abs[Fourier[testData]], PlotRange->Full]
Comments
Post a Comment