Significantly different results between matlab’s fft and FFTW for FIR-filter implementation

I am trying to implement the fast fir-filter in a C++ application.
I have implemented the same code in matlab as a way to double-check my implementation and have ran into a problem.

When running matlab’s fft() and ifft() I get vastly different results when compared to FFTW_FORWARDS and BACKWARDS. I have tried running FFTW with all different planning flags, but every single time it has produced an inferior result to fft().

I am running the filter on quadrature-signals before frequency demodulating them to an amplitude subcarrier. The FFTW-implementation produces more noise. I have also confirmed that the values produced are quite different as well.

The only factors I can see that differ between the two implementations are the FFTs and maybe the implementation of saving audio to a wav-file, though I could not find if Matlab’s audiowrite() may be doing some filtering on the AM-subcarrier.

The resulting spectograms of the two implementations can be found below, with the C++ result being above, and the Matlab result below. They represent the same point in time, over the span of a second.

I am still new to DSP, so any help is greatly appreciatedspectogram


I solved it! Apparently FFTW does not copy down the entire transformation in the r2c-case, because of DFT-symmetry, which was the source of my problem in the filter. They mention it briefly in their documentation.

Read more here: Source link