# Discrepancy between Matlab and Mathematica Fourier parameters [duplicate]

MATLAB and Mathematica have different FFT normalization parameters. This is easy to change in Mathematica with the FourierParameters -> argument, but anything having to do with this in MATLAB seems to have been deprecated, or only working for the non-discrete case. So, I want to try and perform operations on my MATLAB FFT function to have it match the Mathematica one.

I start with fft([1 1 2 2 1 1 0 0]) in MATLAB: Then, exploring with the parameters in Mathematica: Aha! So, the Mathematica parameters, {1, 1}, give me the values I got from MATLAB, while the Mathematica parameters {0, 1}, that are used for default Mathematica FFT behavior, seem to be scaling those of {1, 1} by a factor of (sqrt(2/pi)/2).

But oh no, applying that factor in MATLAB gives me which is close to, but not quite, the data I want. How can I replicate this correctly in MATLAB?

From the documentation, Mathematica defaults to defining y = Fourier[x] as:

$$y_k = \frac1{\sqrt{n}} \sum_{j=1}^n x_j e^{2 \pi i (j-1) (k-1)/n}$$

From the documentation, MATLAB defaults to defining y = fft(x) as:

$$y_k = \sum_{j=1}^n x_j e^{-2 \pi i (j-1) (k-1)/n}$$

MATLAB further defines x = ifft(y) as:

$$x_k = \frac1n \sum_{j=1}^n y_j e^{2 \pi i (j-1) (k-1)/n}$$

As we can see, MATLAB's fft differs in the sign of the exponent from Mathematica's definition which makes it slightly more annoying to use as a substitute (you have to either time reverse things, or conjugate the answer and only work for real valued data), but MATLAB's ifft matches the Mathematica definition in all but normalization.

Thus we can make MATLAB emulate Mathematica's y = Fourier[x] for arbitrary complex data x via:

y = sqrt(length(x)) ifft(x)


We can equivalently also make Mathematica emulate MATLAB's y = fft(x) for real data via:

y = Sqrt[Length[x]] Conjugate[Fourier[x]]


... or, perhaps more idiomatically, and also for complex data:

y = Fourier[x, FourierParameters -> {1, -1}]

• For MATLAB, you would actually use ifft() instead if you want to emulate the Mathematica default: sqrt(length(x)) ifft(x). – J. M.'s discontentment Oct 24 '17 at 23:25
• Sounds better. That also has the right behavior for complex data. I'm not familiar with MATLAB, so I literally just pieced together something that worked from the definitions in the documentation and seemed to work in Octave. I'll edit it. – user3047059 Oct 26 '17 at 9:11