%% Second-Order Section Implementation of a Butterworth Filter
% 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]

% Copyright 2015 The MathWorks, Inc.