I am trying to use C++ and FFTW to get the amplitude, wavelength and phase from a series of numbers without much luck and I was wondering if someone could help me please?
I have searched the Internet but as I am new to FFT I have not been able to find anything specific enough that I understand
I have 370 double values that I am reading from a file into an inputRecord array, E.g. 1.11567, 1.11599, 1.11679
This is what I am doing so far with FFTW:
double *input;
fftw_complex *output;
fftw_plan p;
int binCount = inputCount/ 2; // inputCount = the number of records in the input file
input = (double*)fftw_malloc(sizeof(double) * inputCount);
output = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * inputCount);
p = fftw_plan_dft_r2c_1d(barCount, input, output, FFTW_ESTIMATE);
// Copy the double numbers into the FFTW input array
for (int i = 0; i < barCount; i++)
{
input[i] = inputRecord[i];
}
fftw_execute(p); //performs the fourier transform, fills `output'
I am then looping through the FFTW output array trying to get the amplitude with this calculation: Amplitude = 2 * abs(FFTOutput[i]) / 370
I would also like to get the wavelength (have no idea how) and the phase of the sine wave (no idea how to do this either)
Any help is very much appreciated.