Li Li
2007-May-02 23:06 UTC
[R] Is R's fast fourier transform function different from "fft2" in Matlab?
Hi All, I found "mvfft" in R and "fft2" in Matlab give different result and can't figure out why. My example is: In R:> matrix(c(1,4,2,20), nrow=2)[,1] [,2] [1,] 1 2 [2,] 4 20> mvfft(matrix(c(1,4,2,20), nrow=2))[,1] [,2] [1,] 5+0i 22+0i [2,] -3+0i -18+0i In Matlab:>fft2([1,2;4,20])ans 27 -17 -21 15 Does any function in R generate teh same result as what from Matlab? Thanks, Li [[alternative HTML version deleted]]
Sundar Dorai-Raj
2007-May-03 00:14 UTC
[R] Is R's fast fourier transform function different from "fft2" in Matlab?
Li Li said the following on 5/2/2007 4:06 PM:> Hi All, > > I found "mvfft" in R and "fft2" in Matlab give different result > and can't figure out why. My example is: > > In R: >> matrix(c(1,4,2,20), nrow=2) > [,1] [,2] > [1,] 1 2 > [2,] 4 20 >> mvfft(matrix(c(1,4,2,20), nrow=2)) > [,1] [,2] > [1,] 5+0i 22+0i > [2,] -3+0i -18+0i > > In Matlab: >> fft2([1,2;4,20]) > > ans> > 27 -17 > -21 15 > > Does any function in R generate teh same result as what from Matlab? > Thanks, > > Li >I don't know Matlab or any of its functions, but the following produces the same output. z <- matrix(c(1, 4, 2, 20), nrow = 2) Re(fft(z)) And from ?fft: When 'z' contains an array, 'fft' computes and returns the multivariate (spatial) transform. HTH, --sundar