0
$\begingroup$

First a little background: I’ve looked at the following discussions on StackExchange and still racking my head on Fourier

What are the most common pitfalls awaiting new users?

Discrepancy between Matlab and Mathematica Fourier parameters

Comparing ordinates between FourierTransform and Fourier

Let’s Import the data and define a couple of helper functions.

** waveform data link**

 waveForm = Import[“filename.csv", "CSV”];


myFFT[a : {{_, _} ...}] := 
Module[{time, y, dt, ft, len, front, back, 
freq},(*Extract data and take the Fourier transform*)

time = a[[All, 1]];
y = a[[All, 2]];
dt = time[[2]] - time[[1]];
ft = Abs[Fourier[y, FourierParameters -> {1, -1}]];

(*Identify positive and negative frequencies.Zero frequency mode \
 appears at position 1*)

len = If[EvenQ[Length[ft]], Length[ft] + 1, Length[ft]];
front = Take[ft, Ceiling[len/2]];
back = Reverse[Take[ft, -Floor[len/2]]];
ft = front + PadLeft[back, Length[front]];
(*Make frequency units and return FFT*)
freq = Table[i/dt/Length[a], {i, 0, Length[ft] - 1}];
Transpose[{freq, ft}]]


 integrateList[t_] := Differences[#1].MovingAverage[#2, 2] & @@ 
  Transpose[t]; (*Trapezoidal Rule *)

Let’s compute the power of the signal

 signal = {#1, #2 - 5.1875} & @@@  waveForm; (*Remove DC *)
 signalSquared = {#1, #2^2} & @@@ signal;
 fft = myFFT[signalSquared];

Let’s now do a Parseval’s Theorem sanity check and compare the area under the curve in time domain and frequency domain to make sure that they are equal

 integrateList@signalSquared[[1 ;; All]]
 2*integrateList[fft] (*since we are looking at only half the curve *)

I get the following results:

 > Time Domain Area Under the Curve = 4.9616 e-6
 > Frequency Domain Area Under the Curve = 8.2740 e+8

Clearly a big difference in area! I’ve tried tinkering with the Fourier Parameters but no avail… Any help would be appreciated!

$\endgroup$
  • 1
    $\begingroup$ Where you have i/dt/Length[a] I suspect you want i*dt/Length[a]. There may be other issues but that change at least puts things in the correct ballpark. $\endgroup$ – Daniel Lichtblau Apr 13 '18 at 14:38
  • $\begingroup$ Changing that throws the frequency axis way off…. i/dt/Length[a] gives me the correct frequency range [the time domain signal ~10 MHz broadband pulse] and the gives me the zeros in the right place. $\endgroup$ – Pam Apr 13 '18 at 16:10

Your Answer

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

Browse other questions tagged or ask your own question.