Main Content

# sos2cell

Convert second-order sections matrix to cell array

## Syntax

``cll = sos2cell(sos)``
``cll = sos2cell(sos,g)``

## 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

`$\text{sos}=\left[\begin{array}{cccccc}{b}_{01}& {b}_{11}& {b}_{21}& 1& {a}_{11}& {a}_{21}\\ {b}_{02}& {b}_{12}& {b}_{22}& 1& {a}_{12}& {a}_{22}\\ ⋮& ⋮& ⋮& ⋮& ⋮& ⋮\\ {b}_{0L}& {b}_{1L}& {b}_{2L}& 1& {a}_{1L}& {a}_{2L}\end{array}\right]$`

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

`$H\left(z\right)=g\prod _{k=1}^{L}{H}_{k}\left(z\right)=g\prod _{k=1}^{L}\frac{{b}_{0k}+{b}_{1k}{z}^{-1}+{b}_{2k}{z}^{-2}}{1+{a}_{1k}{z}^{-1}+{a}_{2k}{z}^{-2}}.$`

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