sosfilt

Filter a real signal with a second order section IIR filter.

Syntax

y = sosfilt(sos, x)

Inputs

sos
The polynomial coefficients of the filter. Each row of the matrix contains a second order section, with the three numerator values followed by the three denominator values. The fourth column must not contain any zero elements.
Type: double
Dimension: matrix
x
The signal to be filtered. If x is a matrix, then filtering occurs along the first dimension.
Type: double
Dimension: vector | matrix

Outputs

y
The filtered signal.

Examples

Specify a second order section filter and call sosfilt.

sos = [0.52, 1.04, 0.52, 1.61, -0.95, 1.43;
       0.29, 0.58, 0.29, 1.54, -1.41, 1.05;
       0.07, 0.14, 0.07, 1.40, -1.86, 0.73];
y = sosfilt(sos, x);

Plot the magnitude response of the preceding SoS filter, assuming a sampling frequency of 1000 Hz.

fs = 1000;
f = [0:2:350];
h1 = freqz(sos(1,1:3), sos(1,4:6), f, fs);
h2 = freqz(sos(2,1:3), sos(2,4:6), f, fs);
h3 = freqz(sos(3,1:3), sos(3,4:6), f, fs);
plot(f, abs(h1.*h2.*h3));
xlabel('Frequency');
ylabel('Magnitude');
Figure 1. sosfilt figure 1


Comments

High order IIR filters can suffer from quantization error leading to instability of the poles. A second order section filter avoids this by not convolving the sections into a single filter.