I am trying to use FFTW function for IFFT:

fftw_plan_dft_c2r_1d(size, out_cpx, out, FFTW_ESTIMATE).

My goal is to input desired frequency response data and obtain related coefficients using Inverse Fourier Transform. Since out_cpx is complex, I calculated magnitude (0,1) and phase, taking into account it is linear phase filter. Since I know the phase I calculated real and imaginary parts as Acos(w) and Asin(w) and with these pairs I populated out_cpx[i][0] and out_cpx[i][1]. When I perform Inverse Fourier Transform using fftw_plan_dft_c2r_1d() I assume I am right away getting FIR coefficients h[n] as the result. With these coefficients i go to MATLAB and get response using freqz(C,1) where C holds my coefficients. But I am getting a lot of ripples in my graph for response and for phase. Am I doing something wrong here? It is not clear to me how to specify phase of the desired frequency response.

  • 1
    $\begingroup$ This probably isn't how you want to design a filter. There are numerous better methods for doing so; just Google "digital filter design." $\endgroup$
    – Jason R
    May 15, 2015 at 13:16
  • $\begingroup$ I have already Googled and already got some answers here that point this way. How else would you design FIR filter given specification 6dB @ 1.6kHz and slope 24 dB/octave? One way is to use design IIR Butterworth filter and use its coefficients for FIR. The other is sampled frequency method where you input desired frequency response and get its IFT which gives you coefficients. $\endgroup$ May 15, 2015 at 13:25

1 Answer 1


The ripple you see is due to Gibbs phenomenon and is caused by your filter having a step response. You will have to pass the frequency response through a window function first.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.