Fourier transformation of multidimensional list [closed]

x is a list containing 7 trajectories (Dimensions[x] = {2726, 7}) of which I want to calculate the FFT.

x = Get@”http://pastebin.com/raw/6tX4GBxA”;
sr = 60; (*sampling rate*)
inc = sr/Length[x[[All, 1]]]; (*increment*)
freq = Table[f, {f, 0, sr – inc, inc}] // N;

FFT for first trajectory:

ampFFT = Abs[Fourier[x[[All, 1]], FourierParameters -> {-1, 1}]];

ListLinePlot[Transpose[{freq, ampFFT}],
PlotRange -> {{0, sr/2}, All}, ScalingFunctions -> “Log”,
Frame -> True, FrameLabel -> {{“Amplitude (x)”, “”}, {“f (Hz)”, “”}},
ImageSize -> Medium]

plot 1:

Now I want to calculate the FFT for the whole list at once:

ampFFT = Abs[Fourier[x, FourierParameters -> {-1, 1}]];

From that the FFT for the first trajectory is:

ListLinePlot[Transpose[{freq, ampFFT[[All, 1]]}],
PlotRange -> {{0, sr/2}, All}, ScalingFunctions -> “Log”,
Frame -> True, FrameLabel -> {{“Amplitude (x)”, “”}, {“f (Hz)”, “”}},
ImageSize -> Medium]

plot 2:

What surprises me, plot 2 is different from plot 1. There must be a mistake.

Where is my error?

The same plot 2 is also obtained when I do the following:

ampFFT = Abs[Fourier[# & /@ x, FourierParameters -> {-1, 1}]];

ListLinePlot[Transpose[{freq, ampFFT[[All, 1]]}],
PlotRange -> {{0, sr/2}, All}, ScalingFunctions -> “Log”,
Frame -> True, FrameLabel -> {{“Amplitude (x)”, “”}, {“f (Hz)”, “”}},
ImageSize -> Medium]

My final aim is to calculate the FFT for the whole list at once and plot all FFTs in a single plot:

If I would calculate ampFFT correctly I would do this the following way:

ampFFT = Abs[Fourier[# & /@ x, FourierParameters -> {-1, 1}]];

ListLinePlot[Transpose[{freq, #}] & /@ Transpose[ampFFT],
PlotRange -> {{0, sr/2}, All}, ScalingFunctions -> “Log”,
Frame -> True, FrameLabel -> {{“Amplitude (x)”, “”}, {“f (Hz)”, “”}},
ImageSize -> Medium]

plot 3:

=================

=================

1 Answer
1

=================

Applying Fourier to a multi-dimensional array does a multi-dimensional FFT, so your first case generates the 2D FFT of all the trajectories. In your case you want to map the 1D FFT over each trajectory.

ampFFT = Abs[Fourier[#,FourierParameters->{-1,1}]&/@(Transpose@x);

Now each element of ampFFT is the 1D FFT of one trajectory, i.e. ampFFT[[i]] == Abs@Fourier[x[[All,i]], FourierParameters->{-1,1}]

Another helpful option is DataRange which you can use to specify the x axis without providing an explicit list of x values when your data is evenly sampled. PlotRange can now be specified in the same units as DataRange

ListLinePlot[ ampFFT,
DataRange->{0,sr},
PlotRange->{{0, sr/2},All},
ScalingFunctions->”Log”
]

  

 

Thank you for the solution. Please see this: imgur.com/tQ0HgMZ
– mrz
Jun 2 at 10:29