I wrote Mathematica FFT code that works for non-beat signals, eg. Sin[2*Pi/20*x] and more complicated but I can't obtain beat frequency of Sin[2*Pi*(10)*x] + Sin[2*Pi*(11)*x]. Also, what is general approach for sampling of analytical functions or numerical data in order to extract beat freq, because I think there lies the problem? I understand that Nyquist theorem determines appropriate sampling frequency in order to extract high frequencies.


test[x_] = Sin[2*Pi/20*x]

xi = 0 
xf = 100
h = 1;(*(xf-xi)/n step*)
n = (xf - xi)/h (*# of sampling points*)

N[(1/h)/(n)]  (*sampling frequency*)

xg = N[Range[xi, xf - h, h]];
data = Map[test, xg]

cc = Abs[Fourier[data]]
ccred = Table[If[0 < i < Length[cc]/2, cc[[i]], 0.], {i, Length[cc]}];

Table[Ordering[ccred, -15][[i]], {i, 15}]
Table[ccred[[Ordering[ccred, -15][[i]]]], {i, 15}]

nu = Table[N[((Ordering[ccred, -15][[i]] - 1)*(1/h)/(n))], {i, 15}]
T = Table[N[1/((Ordering[ccred, -15][[i]] - 1)*(1/h)/(n))], {i, 15}]

To get the beat, you have to mix (multiply) the signals, not add them. Try Sin[2*Pi*(10)*x] * Sin[2*Pi*(11)*x.

  • $\begingroup$ en.wikipedia.org/wiki/… I get the beat with this but i can't get beat freq via this code $\endgroup$ – Thela Hun Ginjeet Oct 23 '17 at 0:05
  • 3
    $\begingroup$ John's point is that you cannot see the difference frequency in the raw FFT -- it isn't there. The FFT shows you the two sine waves and only the two sine waves. If you want to see the difference frequency, you will need to introduce a nonlinearity. Multiplying the two signals will work, taking the square of the sum will work. $\endgroup$ – bill s Oct 23 '17 at 1:56
  • $\begingroup$ I tried squaring and it does not work. Also what really interest's me are numerical solutions of some DE and there I will not have the opportunity to manipulate solutions like in this case. $\endgroup$ – Thela Hun Ginjeet Oct 23 '17 at 10:06
  • $\begingroup$ The beat frequency is present in the linearly mixed signal, but it will not appear in the FFT. Either introduce non-linear mixing or merely apply the textbook formula for beat frequency: $f_b = |f_1 - f_2|$. $\endgroup$ – David G. Stork Oct 24 '17 at 1:25
  • $\begingroup$ In the end it worked. I am not sure why was there problem earlier. Sometimes the beat freq is present in the linearly mixed signal, and sometimes it's not. $\endgroup$ – Thela Hun Ginjeet Oct 24 '17 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.