I'm trying to filter a (real) signal in Matlab using the FFT and the inverse FFT (IFFT). I have an IIR filter (coefficients 'b' and 'a'). I'm expecting (approximately?) the same result as if I had simply done this:
filteredSignal = filter(b,a,signal);
So this is what I did:
NFFT = length(signal);
FFTsignal = fft(signal, NFFT);
FilterFreqResponse = freqz(b,a,NFFT);
FFTfilteredSignal = FFTsignal .* FilterFreqResponse;
filteredSignal = ifft(FFTfilteredSignal, NFFT);
And the problem here is that the resulting signal (filteredSignal
) is complex. And I'd like a real signal (as my input signal). The filter
function also returns a real signal. So... what am I doing wrong? Is it impossible to use FFT-based filtering with an IIR filter? I mean: the frequency response of my filter is not symmetric with respect to the origin, so the spectrum of my filtered signal will not be symmetric neither... so the filtered signal in the time domain cannot be real...?
PS: there a "symmetric" option in the ifft function:
filteredSignal = ifft(FFTfilteredSignal, NFFT, 'symmetric');
If I do this, the filteredSignal is now real... but is clearly different (in amplitude and phase) from the one I get using the "filter" function directly. And this "symmetric" option apparently discards the imaginary part, or something like that, so it's probably not a good idea to use it i guess....
Thanks a lot in advance! (and sorry for my English)