Convert digital filter transfer function data to second-order sections form
[sos,g] = tf2sos(b,a)
[sos,g] = tf2sos(b,a,'order')
[sos,g] = tf2sos(b,a,'order','scale')
sos = tf2sos(...)
tf2sos converts a transfer function representation of a given digital filter to an equivalent second-order section representation.
sos is an L-by-6 matrix
whose rows contain the numerator and denominator coefficients bik and aik of the second-order sections of H(z).
'down', to order the sections so the first row of sos contains the poles closest to the unit circle
'up', to order the sections so the first row of sos contains the poles farthest from the unit circle (default)
'none', to apply no scaling (default)
'inf', to apply infinity-norm scaling
'two', to apply 2-norm scaling
Using infinity-norm scaling in conjunction with up-ordering minimizes the probability of overflow in the realization. Using 2-norm scaling in conjunction with down-ordering minimizes the peak round-off noise.
Note Embedding the gain in the first section when scaling a direct-form II structure is not recommended and may result in erratic scaling. To avoid embedding the gain, use ss2sos with two outputs.
Design a Butterworth 4th-order lowpass filter using the function butter. Specify the cutoff frequency as half the Nyquist frequency. Implement the filter as second-order sections. Verify that the two representations are identical by comparing their numerators and denominators.
[nm dn] = butter(4,0.5); [ss gn] = tf2sos(nm,dn) numers = [conv(ss(1,1:3),ss(2,1:3))*gn;nm] denoms = [conv(ss(1,4:6),ss(2,4:6)) ;dn]
ss = 1.0000 2.0000 1.0000 1.0000 -0.0000 0.0396 1.0000 2.0000 1.0000 1.0000 -0.0000 0.4465 gn = 0.0940 numers = 0.0940 0.3759 0.5639 0.3759 0.0940 0.0940 0.3759 0.5639 0.3759 0.0940 denoms = 1.0000 -0.0000 0.4860 -0.0000 0.0177 1.0000 -0.0000 0.4860 -0.0000 0.0177
tf2sos uses a four-step algorithm to determine the second-order section representation for an input transfer function system:
It uses the function zp2sos, which first groups the zeros and poles into complex conjugate pairs using the cplxpair function. zp2sos then forms the second-order sections by matching the pole and zero pairs according to the following rules:
Match the poles closest to the unit circle with the zeros closest to those poles.
Match the poles next closest to the unit circle with the zeros closest to those poles.
Continue until all of the poles and zeros are matched.
tf2sos groups real poles into sections with the real poles closest to them in absolute value. The same rule holds for real zeros.
It orders the sections according to the proximity of the pole pairs to the unit circle. tf2sos normally orders the sections with poles closest to the unit circle last in the cascade. You can tell tf2sos to order the sections in the reverse order by specifying the 'down' flag.
where p can be either ∞ or 2. See the references for details on the scaling. This scaling is an attempt to minimize overflow or peak round-off noise in fixed point filter implementations.
 Jackson, L. B. Digital Filters and Signal Processing. 3rd ed. Boston: Kluwer Academic Publishers, 1996, chap. 11.
 Mitra, S. K. Digital Signal Processing: A Computer-Based Approach. New York: McGraw-Hill, 1998, chap. 9.
 Vaidyanathan, P. P. "Robust Digital Filter Structures." Handbook for Digital Signal Processing (S. K. Mitra and J. F. Kaiser, eds.). New York: John Wiley & Sons, 1993, chap. 7.