# How can I obtain a zero-filled Fourier transform, as produced by MATLAB's fft?

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?

-

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.
@bucherer apparently MATLAB uses a different normalization than does Mathematica, but since I'm not a MATLAB user I didn't know this previously. The option FourierParameters controls the normalization. See the edit to the answer--I've now verified that Mathematica and MATLAB give identical results. –  Oleksandr R. Jan 3 '13 at 12:51