Hi, I am using the fftw library to perform a Fourier Transform on data that I read from a file and then output the transform into a new file.
I have compiled the library and it all links and seems to work just fine. However when It comes to actually performing the transform the output is just wrong. Here is what I put in and the output:
What is inputed:
1 2 3 4
0.218418
0.218418
0.218418
0.218418
What is outputted:
1 2 3 4
0.873672
0
0
0
Here is my code that involves reading the data into a file, performing the transform and outputting the data:
What kind of data do you want to do a fourier tansform on?
My only experience is with FFTreal on audio data. For what I was doing, you choose an fft size (number of sample values) to pass in. You discard the second half of your output because your limited by half your sample rate (nyquist rate). Then you calculate what frequency your bins (real and imaginary pairs / complex numbers) are associated with.
f[i] = i * samplerate / fftsize;
where f[i] is the frequency you have data for at bin i.
I'm not sure what you should expect to get as output when you input
0.218418
0.218418
0.218418
0.218418
I noticed that when using FFTreal, I would not get good output for this type of input without any oscillation. And with only four input values, your only going to get two usable bins, the first bin would be the first 1/4 of the sample rate, and the second, the second quarter.
Also with FFTreal, you input your sample values as real numbers, and you input your imaginary numbers as all 0's. Then it spits out the same two vectors processed.
Your data has no oscilation, which means it has a frequency of 0.
0.873672, is 4 times your input, 0.218418. I guess that is the real component of bin 1? That is supposed to be the amplitude of the component cosine waves of the bin.