0
$\begingroup$

If I have my list peaks from a Fourier transform of a list of values, how can I find the period / amplitude / function approximation of that original list of values from those peaks? I have seen variations of this question elsewhere on SE, and the responses are comprehensive, but they do not appear to simply and directly answer the original question.

$\endgroup$
4
$\begingroup$

Here's an interactive version... put the signal you want analyzed in sig, and choose how many points you want to use in the reconstruction.

sig = Table[TriangleWave[5 t], {t, 0, 1, 0.01}];
lenSig = Length[sig];
Manipulate[Module[{},
  fftY = Fourier[sig, FourierParameters -> {1, -1}];
  mag = Abs[fftY]/lenSig; phase = Arg[fftY];
  ordMag = Ordering[mag, All, GreaterEqual];
  rec = Total[Table[mag[[ordMag[[k]]]] 
               Cos[2 Pi (ordMag[[k]] - 1) (n - 1)/lenSig + phase[[ordMag[[k]]]]], 
                    {k, 1, numTerms}, {n, 1, lenSig}]];
  GraphicsRow[{ListPlot[{Tooltip[mag, "not used"], 
      Tooltip[Thread[{ordMag[[1 ;; numTerms]], 
         mag[[ordMag[[1 ;; numTerms]]]]}], "used in reconstruction"]},
      Filling -> Axis, PlotRange -> All, 
      PlotLabel -> "Fourier Transform of Signal", 
      PlotStyle -> {Blue, {Black, PointSize[0.015]}}], 
     ListLinePlot[{Tooltip[sig, "signal"], Tooltip[rec, "reconstruction"]}, 
     PlotLabel -> "Signal (blue) and Reconstructed Signal (brown)", 
     PlotRange -> All, Filling -> {1 -> {2}}]}, ImageSize -> 800]],
 {{numTerms, 5, "number of terms in reconstruction"}, 1, 10, 1, Appearance -> "Labeled"}]

enter image description here

To see where the reconstruction comes from: first, choose the numTerms largest of the peaks for reconstruction. The frequencies of these peaks and the phases go inside the Cos term. The magnitudes of the peaks multiply the Cos term. The Total command sums them up.

$\endgroup$
  • $\begingroup$ Thank you so much... but I am completely lost. How did you make that reconstruction? I don't understand where the reconstruction comes from. $\endgroup$ – user3769181 Jun 6 '17 at 5:14
  • $\begingroup$ I've added a few words about how the reconstruction is done. $\endgroup$ – bill s Jun 6 '17 at 12:13

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