Re: [R] Is R's fast fourier transform function different from "fft2" in Matlab?
Li Li said the following on 5/2/2007 7:53 PM: > 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? This is easily explained if you read ?fft and the description of the 'inverse' argument in the Value section. Please do read the help pages as the posting guide suggests. Re(fft(temp, inverse = TRUE)/4) --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is R's fast fourier transform function different from "fft2" in Matlab?
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: [EMAIL PROTECTED] Least Cost Formulations, Ltd.URL: http://lcfltd.com/ 824 Timberlake Drive Tel: 757-467-0954 Virginia Beach, VA 23464-3239Fax: 757-467-2947 "Vere scire est per causas scire" __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is R's fast fourier transform function different from "fft2" in Matlab?
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? Thanks, Li On 5/2/07, Sundar Dorai-Raj < [EMAIL PROTECTED]> wrote: > > > 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 > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [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,]12 > [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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[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,]12 [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]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.