[R] Is R's fast fourier transform function different from "fft2" in Matlab?

Robert A LaBudde ral at lcfltd.com
Thu May 3 05:43:55 CEST 2007


Discrete Fourier transforms can be normalized in different ways.

Some apply the whole normalization to the forward transform, some to 
the reverse transform, some apply the square root to each, and some 
don't normalize at all (in which case the reverse of the forward 
transform will need scaling).

The latter apparently the case with R, according to your values.

Note that the R and the MatLab answers agree to within a scale factor 
for each row.

At 10:53 PM 5/2/2007, Li-Li wrote:
>Thanks for both replies.
>Then I found the "ifft2" from Matlab gives different result from "fft( ,
>inverse=T)" from R.
>An example:
>in R:
> > temp  <- matrix(c(1,4,2, 20), nrow=2)
> > fft(temp)
>        [,1]   [,2]
>[1,]  27+0i -17+0i
>[2,] -21+0i  15+0i
> > fft(temp,inverse=T)
>        [,1]   [,2]
>[1,]  27+0i -17+0i
>[2,] -21+0i  15+0i
>
>In Matlab:
> > A = [1,2;4,20];
> > fft2(A)
>Ans =
>    27    -17
>   -21     15
> >ifft2(A)
>Ans=
>    6.7500    -4.2500
>   -5.2500      3.7500
>
>I also tried mvfft with inverse but can't get same result with "ifft2". Does
>any function work?

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: ral at lcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"



More information about the R-help mailing list