Main Content

sos2cell

Convert second-order sections matrix to cell array

Description

cll = sos2cell(sos) generates a cell array cll containing the coefficients of the filter system described by the second-order section matrix sos.

example

cll = sos2cell(sos,g) also specifies a scale gain g to append in the cell array representation cll of the system specified in sos.

Examples

collapse all

Generate a lowpass elliptic filter of order 4 with 0.5 dB of passband ripple and 20 dB of stopband attenuation. The passband edge is 0.6 times the Nyquist frequency. Convert the transfer function to a matrix of second-order sections.

[b,a] = ellip(4,0.5,20,0.6);
m = tf2sos(b,a);

Use sos2cell to convert the 2-by-6 matrix produced by tf2sos into a 1-by-2 cell array, c, of cells. Display the second entry in the first cell of c. Verify that it contains the denominator coefficients of the first second-order section of m.

c = sos2cell(m);
compare = [c{1}{2};m(1,4:6)]
compare = 2×3

    1.0000    0.1677    0.2575
    1.0000    0.1677    0.2575

Input Arguments

collapse all

Second-order section matrix representation, specified as an L-by-6 matrix, where L is the number of second-order sections. The matrix

sos=[b01b11b211a11a21b02b12b221a12a22b0Lb1Lb2L1a1La2L]

represents the second-order sections of H(z):

H(z)=gk=1LHk(z)=gk=1Lb0k+b1kz1+b2kz21+a1kz1+a2kz2.

Example: [z,p,k] = butter(3,1/32); sos = zp2sos(z,p,k) specifies a third-order Butterworth filter with a normalized 3 dB frequency of π/32 rad/sample.

Data Types: single | double
Complex Number Support: Yes

Scale gain, specified as a scalar.

Data Types: single | double
Complex Number Support: Yes

Output Arguments

collapse all

Second-order section cell-array representation, returned as a row cell array with the following size:

  • L elements — If g equals 1 or if you do not specify it. Each element of the cell array corresponds to a second order section. For example, the cell array element cll(k) contains the coefficients from the kth section of sos.

    cll{k} = {sos(k,1:3) sos(k,4:6)}

  • L+1 elements — If g is different from 1. The first element of cll contains the gain specified in g. Each subsequent element of the cell array corresponds to a second order section. For example, the cell array element cll{k+1} contains the coefficients from the kth section of sos.

    cll{1} = {g 1}
    cll{k+1} = {sos(k,1:3) sos(k,4:6)}

Tips

  • You can use sos = cell2sos(cll) to perform the reverse operation of cll = sos2cell(sos).

Version History

Introduced before R2006a

See Also

|