Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

share|improve this answer
1  
Thanks for your suggestions. I had tried PadRight command to add several additional zero numbers behind original vector in the Mathematica and check the results with Matlab. But final results from both are different. Why? if the padding sequence between both are different? In Matalb, fft(X,n) command only describes to add with trailing zeros to length n but not verify from right or left side of original vector. Is it the problem? –  bucherer Jan 3 '13 at 3:03
1  
@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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.