help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with FFT and IFFT


From: Joe Koski
Subject: Re: Problems with FFT and IFFT
Date: Tue, 28 Feb 2006 09:54:33 -0700
User-agent: Microsoft-Entourage/11.2.1.051004

Keith,

I suspect that you did it correctly, but shouldn't it be real(x2) and
imag(x2) after the fft/ifft?

Joe


on 2/28/06 9:37 AM, Keith Goodman at address@hidden wrote:

> On 2/28/06, Sascha Berkenkamp <address@hidden> wrote:
>> Hi,
>> 
>> I've got a simple problem with the FFT and the IFFT function.
>> I have got one function from matlab with both functions in it. But I
>> will not get the same results. So I started with testing on simple
>> task.
>> I have got a signal, transform it to the frequenz-domain and then I
>> transform it back to the time-domain.
>> Generally after transforming the signal shout be the same than the
>> input signal.
>> So my input signal (x) has no imag-part. So my retransformed signal
>> shoud have no imag-part, too.
>> 
>> fs = 0:0.1:10;
>> x = sin(2*pi*fs);
>> real(x)
>> imag(x)
>> X  = fft(x);
>> x2 = ifft(X);
>> real(x)
>> imag(x)
>> 
>> But in my octave version (octave 2.1.72 from debian etch) the
>> imag-part of the retransformed signal is not zero.
>> 
>> When I put the code into matlab, everything is okay: no imag-part
>> after retransforming into the time-domain.
>> 
>> Sascha
> 
> Here's what I get (no imaginary part; I get the same result in 2.1.72):
> 
> $ octave
> Octave 2.9.4 Forge 20050613
>>> fs = 0:0.1:10;
>>> x = sin(2*pi*fs);
>>> real(x)
> ans =
> 
>  Columns 1 through 12:
>    0.00000   0.58779   0.95106   0.95106   0.58779   0.00000  -0.58779
>  -0.95106  -0.95106  -0.58779  -0.00000   0.58779
>  Columns 13 through 24:
>    0.95106   0.95106   0.58779   0.00000  -0.58779  -0.95106  -0.95106
>  -0.58779  -0.00000   0.58779   0.95106   0.95106
>  Columns 25 through 36:
>    0.58779   0.00000  -0.58779  -0.95106  -0.95106  -0.58779  -0.00000
>   0.58779   0.95106   0.95106   0.58779   0.00000
>  Columns 37 through 48:
>   -0.58779  -0.95106  -0.95106  -0.58779  -0.00000   0.58779   0.95106
>   0.95106   0.58779   0.00000  -0.58779  -0.95106
>  Columns 49 through 60:
>   -0.95106  -0.58779  -0.00000   0.58779   0.95106   0.95106   0.58779
>   0.00000  -0.58779  -0.95106  -0.95106  -0.58779
>  Columns 61 through 72:
>   -0.00000   0.58779   0.95106   0.95106   0.58779  -0.00000  -0.58779
>  -0.95106  -0.95106  -0.58779  -0.00000   0.58779
>  Columns 73 through 84:
>    0.95106   0.95106   0.58779   0.00000  -0.58779  -0.95106  -0.95106
>  -0.58779  -0.00000   0.58779   0.95106   0.95106
>  Columns 85 through 96:
>    0.58779  -0.00000  -0.58779  -0.95106  -0.95106  -0.58779  -0.00000
>   0.58779   0.95106   0.95106   0.58779   0.00000
>  Columns 97 through 101:
>   -0.58779  -0.95106  -0.95106  -0.58779  -0.00000
> 
>>> imag(x)
> ans =
> 
>  Columns 1 through 42:
>   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
> 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  Columns 43 through 84:
>   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
> 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  Columns 85 through 101:
>   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
> 
>>> X  = fft(x);
>>> x2 = ifft(X);
>>> real(x)
> ans =
> 
>  Columns 1 through 12:
>    0.00000   0.58779   0.95106   0.95106   0.58779   0.00000  -0.58779
>  -0.95106  -0.95106  -0.58779  -0.00000   0.58779
>  Columns 13 through 24:
>    0.95106   0.95106   0.58779   0.00000  -0.58779  -0.95106  -0.95106
>  -0.58779  -0.00000   0.58779   0.95106   0.95106
>  Columns 25 through 36:
>    0.58779   0.00000  -0.58779  -0.95106  -0.95106  -0.58779  -0.00000
>   0.58779   0.95106   0.95106   0.58779   0.00000
>  Columns 37 through 48:
>   -0.58779  -0.95106  -0.95106  -0.58779  -0.00000   0.58779   0.95106
>   0.95106   0.58779   0.00000  -0.58779  -0.95106
>  Columns 49 through 60:
>   -0.95106  -0.58779  -0.00000   0.58779   0.95106   0.95106   0.58779
>   0.00000  -0.58779  -0.95106  -0.95106  -0.58779
>  Columns 61 through 72:
>   -0.00000   0.58779   0.95106   0.95106   0.58779  -0.00000  -0.58779
>  -0.95106  -0.95106  -0.58779  -0.00000   0.58779
>  Columns 73 through 84:
>    0.95106   0.95106   0.58779   0.00000  -0.58779  -0.95106  -0.95106
>  -0.58779  -0.00000   0.58779   0.95106   0.95106
>  Columns 85 through 96:
>    0.58779  -0.00000  -0.58779  -0.95106  -0.95106  -0.58779  -0.00000
>   0.58779   0.95106   0.95106   0.58779   0.00000
>  Columns 97 through 101:
>   -0.58779  -0.95106  -0.95106  -0.58779  -0.00000
> 
>>> imag(x)
> ans =
> 
>  Columns 1 through 42:
>   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
> 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  Columns 43 through 84:
>   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
> 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
>  Columns 85 through 101:
>   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
> 
>>> 
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]