[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems with FFT and IFFT
From: |
Keith Goodman |
Subject: |
Re: Problems with FFT and IFFT |
Date: |
Tue, 28 Feb 2006 08:45:00 -0800 |
Should the last line in your example be imag(x2)? Matlab gives zero
and Octave gives eps:
>> eps
eps = 2.2204e-16
>> imag(x2)
ans =
Columns 1 through 9:
0.0000e+00 -2.6382e-17 1.8793e-17 -1.1891e-16 -8.2877e-17
-3.6586e-18 3.9801e-17 2.2479e-16 -6.5572e-17
Columns 10 through 18:
-5.4014e-17 -1.4229e-17 -2.0445e-17 -1.0258e-16 7.1639e-17
2.3891e-18 -1.0553e-16 -3.6597e-17 1.4245e-17
Columns 19 through 27:
-9.8162e-17 -2.1105e-16 -8.5868e-17 -9.7389e-17 5.3450e-17
-8.7306e-17 -1.0856e-16 -1.7588e-17 6.4697e-17
Columns 28 through 36:
-6.6063e-17 -7.0988e-18 9.6732e-17 1.2092e-16 -1.5921e-17
5.4349e-18 1.0205e-16 -5.5355e-17 -1.8688e-16
Columns 37 through 45:
-7.2788e-17 -6.9880e-17 -7.0351e-17 -7.2984e-17 1.0605e-16
-7.0351e-17 -1.4646e-17 -1.7588e-17 2.5443e-17
Columns 46 through 54:
-2.3834e-16 8.4440e-19 -2.9011e-18 -9.3385e-17 1.1913e-16
-1.3026e-16 -2.8030e-17 -5.5824e-17 -4.1861e-17
Columns 55 through 63:
1.3379e-16 -1.5866e-17 2.5757e-16 -1.4229e-17 3.5175e-17
2.2798e-17 1.3191e-16 -3.0879e-18 5.4349e-18
Columns 64 through 72:
-1.0553e-16 9.2741e-17 1.1065e-16 1.5094e-16 -3.0456e-17
-7.5940e-17 6.0831e-17 -3.7655e-17 -5.0565e-17
Columns 73 through 81:
-7.0351e-17 -1.4254e-17 5.1041e-17 3.8263e-17 3.5175e-17
6.0878e-17 4.8140e-17 2.9795e-17 5.6268e-18
Columns 82 through 90:
1.5739e-16 1.8467e-16 2.2967e-16 1.0479e-16 -2.3657e-17
1.2311e-16 -9.0447e-17 -1.0048e-16 1.4024e-16
Columns 91 through 99:
9.2517e-18 -5.7259e-17 -6.6003e-17 2.3036e-16 -1.3951e-16
-9.1052e-17 -3.6107e-17 6.7637e-17 5.2262e-17
Columns 100 and 101:
2.4331e-17 8.7938e-18
On 2/28/06, Keith Goodman <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
-------------------------------------------------------------
- Problems with FFT and IFFT, Sascha Berkenkamp, 2006/02/28
- Re: Problems with FFT and IFFT, Keith Goodman, 2006/02/28
- Re: Problems with FFT and IFFT,
Keith Goodman <=
- Re: Problems with FFT and IFFT, John W. Eaton, 2006/02/28
- Re: Problems with FFT and IFFT, Dmitri A. Sergatskov, 2006/02/28
- Re: Problems with FFT and IFFT, Sascha Berkenkamp, 2006/02/28
- Re: Problems with FFT and IFFT, John W. Eaton, 2006/02/28
- Re: Problems with FFT and IFFT, Joe Koski, 2006/02/28
- Re: Problems with FFT and IFFT, Quentin Spencer, 2006/02/28
- Re: Problems with FFT and IFFT, Joe Koski, 2006/02/28
- Re: Problems with FFT and IFFT, Bill Denney, 2006/02/28
- Re: Problems with FFT and IFFT, Steve C. Thompson, 2006/02/28
- RE: Problems with FFT and IFFT, Frank Palazzolo, 2006/02/28