MATLAB: Tf2sos of iirnotch giving different results

iirnotchtf2sos

Hi,
I am trying to use iirnotch() for filtering, I noticed that if I ran the coefficients from iirnotch (2nd order) through tf2sos (still comes out to be the exact same numbers), the frequency response of (b,a) and (sos) showed in freqz() or fvtool() gives very different results.
eg: [b,a] = iirnotch(wo,bw); [sos1] = tf2sos(b,a); freqz (b, a, Fs); freqz (sos, Fs);
I was wondering how come there is a difference?

Best Answer

You didn’t post the details of your code so I can only provide a general reply. As the documentation states, the second-order-section (‘sos’) implementation of a filter characteristically produces the most stable version of the filter. The transfer function (‘tf’) is usually less stable. Therefore, the plotted filter passband-stopband characteristics may be different between the two implementations. (I convert to and use the ‘sos’ implementation whenever I design a filter.)