The MATLAB FFT function, fft(X,n), can be used to return the n-point DFT. This effectively extends the original signal, X, to n points if n is larger than the dimension of X. But, with the Fourier function in Mathematica, the transform always has the same dimensions as X. So, how can I obtain the same behaviour in Mathematica as implemented in MATLAB?
Asked
Active
Viewed 1,086 times
14
Sjoerd C. de Vries
- 65,815
- 14
- 188
- 323
bucherer
- 141
- 3
1 Answers
19
Based on the MATLAB documentation, it would appear that this is accomplished by simple zero-filling. As such, you can obtain the same result in Mathematica using
Fourier[PadRight[list, n, 0.], FourierParameters -> {1, -1}]
where list is your signal and n is the desired length. For a multidimensional FFT, replace n with {n1, n2, ...}, where n1, n2, &c., are the lengths at each level. FourierParameters -> {1, -1} is not necessary to obtain the zero-filled transform, but accounts for the different normalization factors used by each program, so that the result will now be identical to that given by MATLAB.
N.B.: specifying 0. as the padding specification (rather than the default of simply 0) ensures that a packed array is produced by PadRight when one is given in the input.
Oleksandr R.
- 23,023
- 4
- 87
- 125
FourierParameterscontrols the normalization. See the edit to the answer--I've now verified that Mathematica and MATLAB give identical results. – Oleksandr R. Jan 03 '13 at 12:51