OP's apparent intention:
tf = 60;
NN = (tf)/0.001;
dt = tf/NN;
data = Table[Sin[t], {t, 0., tf, 0.001}];
fft = Fourier[data];
peak1 = First@First[Position[Abs[fft], Max[Abs[fft]]]]
freq = (peak1 - 1)/tf
(*
11
0.166667
*)
It's closest estimate possible, since the adjacent estimates have a larger error:
1/(2 Pi) - (peak1 - {0, 1, 2})/tf // N
(* {-0.0241784, -0.00751172, 0.00915494} *)
Here is the method from the docs for Fourier
(under "Applications"), which uses a more sophisticated approach:
Min[TakeLargest[Abs@fft, 2]];
peaks = Position[Abs[fft], x_ /; x >= %];
pos = First@First[peaks]
(* 11 *)
n = Length@fft;
fr = Abs[Fourier[data*Exp[2 Pi I (pos - 2) N[Range[0, n - 1]]/n],
FourierParameters -> {0, 2/n}]];
frpos = Position[fr, Max[fr]][[1, 1]];
period = N[n/(pos - 2 + 2 (frpos - 1)/n)] dt
(* 6.29278 *)
frequency = 1/period
1./(2 Pi)
(*
0.158912
0.159155
*)
2 Pi
in formula forFourier
. Shouldn't the frequency be(peak1 -1)/tf
? $\endgroup$Sin[2 pi f]
for frequency f. You also need to take a look at the FourierParameters option of Fourier and finally, you should account for your sampling rate too. $\endgroup$Fourier
for an example of how to determine the frequency. The shortcoming of that example is that it uses adt
(ordx
) of1
, and doesn't show how to modify the various steps. However, it's not hard to figure out. $\endgroup$