In order to produce a smooth sine wave (Sin) and visualize it (ListPlot), I seem to need a very high sample rate (much higher than Nyquist).
I want to know if this is a artifact of ListPlot or Sin and am using Fourier (discrete Fourier Transform) to examine the outputs but am finding a feature that is even more confusing.
Sig should generate a tone (10000 hz) of variable duration.
FD should plot the signal in the Frequency domain (in this case: a peak at 10000)
The output of Sig, sampled 400 kHz is shown in the top panel.
Note that I am only plotting a small sample of time.
The output of FD is in the bottom panel. The odd thing is that the frequency appears to be sensitive to signal duration, which is both unexpected and wrong.
Sig[duration_] :=
Module[{int = N@1/400000},
Table[{t, Sin[2*\[Pi]*10000*t]}, {t, int, duration, int}]];
FD[duration_] := Module[{},
fresp = Partition[
Riffle[
Table[x, {x, 0, 21998, 2}],
Abs[Fourier[Sig[duration][[;; , 2]]]]
[[2 ;; 11000]]]
, 2]]
dur = 0.1; testSig = Sig[dur]; testFD = FD[dur];
GraphicsColumn[{ListPlot[testSig[[1000 ;; 1100, 2]], Joined -> True],
ListLogLinearPlot[testFD, Joined -> True, PlotRange -> All]}]
dur = 0.1; testSig = Sig[dur]; testFD = FD[dur];
GraphicsColumn[{ListPlot[testSig[[1000 ;; 1100, 2]], Joined -> True],
ListLogLinearPlot[testFD, Joined -> True, PlotRange -> All]}]
dur=
are exactly identical. $\endgroup$Partition[Riffle[....],2]
as in this question. Please don't propagate this style. Thanks. $\endgroup$