I have some trouble with calculating frequency after Fourier transform. My code:
fB = 1.0;
TimeStart = 0;
TimeEnd = 5;
Data1 = Table[Sin[2 Pi fB x], {x, 0, 5, 1/10}];
sra = 10./1;
inco = sra/Length[Data1];
fresa = Table[f, {f, 0, sra - inco, inco}];
ListPlot[Transpose[{fresa, Flatten[Abs[Fourier[Data1]]]}],
Joined -> True, Frame -> True,
FrameLabel -> {Row[{Style["Frequency, (a.u.)", FontSlant -> Italic,
FontSize -> 15]}], Row[{Style["Amplitude, (a.u.)", FontSlant -> Italic,
FontSize -> 15]}]}, LabelStyle -> Blue,
FrameTicksStyle -> Directive[Orange, 15], ImageSize -> 900,
PlotStyle -> {Red}, Joined -> True, AspectRatio -> 0.5,
PlotRange -> {All, All}, Epilog -> {PointSize[0.003],
Point[Transpose[{fresa, Flatten[Abs[Fourier[Data1]]]}]]}]
To find frequency I have next part of code:
Data21 = Flatten[Abs[Fourier[Data1]]];
Pos = Position[Data21, Max[Data21]][[1, 1]]
gf = (Pos - 1)/((TimeEnd - TimeStart))
result is:
1.0 Hz
Is there any more accurate way to determine the frequency than the one above? Cause if we tried to change parametrs slowly, we don's see changing of frequency. For example if we change fB from 1.0 to 1.08. From sin graph we can see that frequency rises.
When fB = 1.0
When fB = 1.08
Programm calculate that frequency in both cases is 1 Hz.
Fourier
. Direct fitting is a good approach see here to look at that. I also asked your question on Signal Processing Stack Exchange and got some thoughts there. $\endgroup$