I have data corresponding to time and amplitude of a sound wave. The times are in even intervals (i.e. a measurement is taken every second). x[i] is the time of the ith measurement and y[i] is the corresponding amplitude at that time. How do I take the FFT of this data so that I have it in the frequency domain?
Any help would be greatly appreciated. Thank you in advance.
You want the āR2Cā option. See FFTW documentation for the correspondence between the output bins and physically meaningful frequencies. I believe that you must also have FFTW installed and you have to have configured ROOT to use it when you installed ROOT (see ROOTās installation instructions). Hope that helps.
Yes - thank you, I have already looked over that tutorial a great deal. It is difficult to understand because the tutorial does a number of different things all in the same code. Iām not sure what applies directly to my problem. Could anyone please tell me which parts of the code specifically to use? Again, Iām only trying to take the FFT of the data. Shouldnāt it be fairly straightforward?
This may not be much simpler, but it is the simplest example I have that does a FFT like you want. I use it to transform time domain signals into frequency domain. It makes a simulated white noise time domain signal (or you can comment lines 55-60 and uncomment the lines above for a sawtooth wave). It will plot the original signal, the magnitude and phase of the complex transform and then do the inverse transform to show that you get back exactly the original signal (if you are careful about the way FFTW handles normalizations). The plots down the right column are some diagnostics that are likely not interesting to you (I wanted to diagnose the whiteness of my simulated noise). This file needs to be compiled, but I imaging you can easily run it in the CINT interpreter. main.cpp (4.76 KB)
The step that fails is where I try to actually take the fft. Again, my data is in arrays called x and y where x is the time and y is the amplitude. If I try:
In the example posted by Brent, fft_inv is used for the inverse transform. But the one I want is the regular transform (R2C). So in Brentās example, fft is what corresponds to y in my code.
y is an array with the amplitudes corresponding to the times given by x. Remember, this data is just representing a sound wave. Iām not sure what to do with my data to make the ->FFT work properly.