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

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Wed, 02 May 2007 20:45:17 -0700

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_at_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. Received on Thu 03 May 2007 - 04:03:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 May 2007 - 04:31:40 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.