TransWikia.com

How to analyse raw data to obtain frequency and phase from FFT?

Mathematica Asked on July 14, 2021

I have some data from an experiment which has multiple "nodes" (dominant sine wave components) and some noise. I want to use FFT to find the amplitude and phase of these dominant components.

Currently, by editing the output of the Fourier function, i have managed to make a function to get the dominant frequencies.

I was wondering if there is a way to find the phase as well? (as well as sort it to only see the phase for the dominant components)

This is the code for the FFT function:

FFT[list_, tstep_, [Omega]max_, n_] := 
  Module[{FTlist = Abs[Fourier[list]], 
    totaltime = Length[list] tstep, [CapitalDelta][Omega], 
    completeFFTlist, plot, peaks, [CapitalOmega]peak},
   [CapitalDelta][Omega] = N[(2 [Pi])/totaltime];
   completeFFTlist = 
    Delete[Flatten[
      Last[Reap[
        For[i = 1, (2 [Pi] (i - 1))/totaltime > [Omega]max [Nor] 
          i > Length[FTlist], i++, 
         Sow[{N[(2 [Pi] (i - 1))/totaltime], FTlist[[i]]/
           Max[FTlist]}]]]], 1], 1];
   plot = 
    ListLinePlot[completeFFTlist, 
     PlotRange -> {{0, [Omega]max}, All}, Frame -> True, 
     PlotStyle -> {SBlue, Thickness[0.005]}, 
     FrameLabel -> {"Angular Frequency (rad/s)", 
       "Power (Arbitrary units)"}, LabelStyle -> Directive[50], 
     PlotTheme -> "Classic"];
   peaks = 
    Sort[FindPeaks[completeFFTlist[[All, 2]]], #1[[2]] > #2[[2]] &];
   peaks = If[peaks[[1, 1]] == 1, Delete[peaks, 1], peaks];
   [CapitalOmega]peak = 
    Table[completeFFTlist[[peaks[[i, 1]], 1]], {i, 1, n}];
   Return[{[CapitalOmega]peak, [CapitalDelta][Omega], 
     completeFFTlist, plot}]];

This just makes a nice plot and tells me the n frequencies with the highest intensity/amplitude.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP