0

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.

Paul R
  • 208,748
  • 37
  • 389
  • 560
John
  • 11
  • 1
  • 3
  • Wavelength = Velocity / Frequency. Phase needs to be measured relative to something. – Paul R May 26 '19 at 13:31
  • Thanks for the reply. I don't have any velocity or frequency or velocity measurements. Not sure if velocity would apply in this case though. – John May 27 '19 at 11:03
  • Frequency can be determined from your sampling rate and the FFT bin index of your spectral peak. Velocity is the velocity of your wave in whatever medium it’s travelling in. Maybe you could add some more context to your question as it’s rather vague at the moment ? – Paul R May 27 '19 at 15:39

0 Answers0