MATLAB: Comparison of IIR filters

butterworthchebyshev type ichebyshev type iifilter

Hi, I am new to signal processing and matlab and I would appreciate your help.. I want to use a bandpass filter to filter my data between the frequencies of 5Hz and 30Hz. My sampling rate is 250Hz and I assumed passband ripple and stopband attenuation 3 and 40dB respectively. What I have been doing so far is:
[n,Wn] = buttord(Wp,Ws,Rp,Rs);
[z,p,k] = butter(n,Wn,'bandpass');
[sos,g] = zp2sos(z,p,k);
filteredSignal_butter = filtfilt(sos,g,unfilteredSignal);
I tried the same with Cheby1,2 and elliptic filters. My problem is that: a.the filtfilt is supposed to zero-phase digital filtering while I see something different than a horizontal line in the phase response (filter visualisation tool), b. I don't know how to assess which of the filters used provide the best filtering of my data. I can see the obvious differences in the final form of the waveform but when the form of the signal is similar but just the magnitudes change then how do I chose? and c. with what criteria (practically) do we choose the ideal passband ripple and stopband attenuation?

Best Answer

Your approach appears to be correct. Remember to divide your passband and stopband frequencies by your Nyquist frequency (here 125 Hz) to normalise them.
a. The fvtool graphics are telling you the characteristics of your filter, not the filtering process using filtfilt, that actually produces a maximally-flat-phase filter response.
b. The filter design you choose depends on the result you want. Your lower frequency (at 5 Hz) may make a Chebyshev design more practical, because you have a narrow stopband-to-passband transition in that region. An elliptic filter could give you the same benefits with that. A Butterworth filter can handle that, but takes a bit more effort to design. And then you have to consider the passband and stopband ripple you can tolerate, neither of which is a practical consideration with the flat passband and stopband of a Butterworth filter.
c. Whatever works best with your signal. Filter design (in my experience) is largely heuristic. I usually begin with a Butterworth design because of the flat passband and stopband characteristics. If I need a steep rolloff (for example as you do at the low end), and if the Butterworth filter cannot give the response I want, I consider a Chebyshev II filter because of the flat passband. Another possibility is a relatively high-order FIR filter (see the fir1 documentation).
Note that this is my approach. There is no one best approach, as there is no one best filter design. You have to decide what characteristics are most important, and choose the design that best meets your needs.