Forums

Problem using fftw

Started by Vedran Fura─Ź September 7, 2007
I'm transforming one period of a sawtooth signal:
-1, -0.998, -0.996, -0.994, ..., +0.994, +0.996, +0.998.

The fftw plan I use is: fftw_plan_dft_r2c_1d(N, in, out, FFTW_ESTIMATE);

This is the result that I expect:

-0.636sin(x) -0.318sin(2x) -0.212sin(3x) -0.159sin(4x) -0.127sin(5x)...

And this is what I get:

+0.636sin(x) +0.318sin(2x) +0.212sin(3x) +0.159sin(4x) +0.127sin(5x)...

As you can see, the absolute values are correct, but signs are not and th=
e
reconstructed signal is mirrored vertically. Why is that? Am I overlookin=
g
something?

TIA

Vedran Fura=C4=8D

Pure speculation, but it could be a misinterpretation of the result:

In the frequency domain, a real-valued "1" in the first bin means a cosine
wave of the fundamental frequency (in combination with a real-valued "1" in
the last bin). So far so good.

But 1i in combination with -1i in the last bin is MINUS sine. Mixing this
up exchanges positive and negative frequencies => reverse the time axis.

-mn
>> a real-valued "1" in the first bin
Brain damage by prolonged exposure to C... The _first_ bin is DC. Example for cos: 0 1 0 0 0 0 0 1 Cheers Markus
I forgot to post this earlier, an example using FFTW in C:

http://www.elisanet.fi/mnentwig/webroot/FFTW_example/index.html

Cheers

Markus