# cell2sos

Convert second-order sections cell array to matrix

## Syntax

``sos = cell2sos(cll)``
``[sos,g] = cell2sos(cll)``

## Description

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

example

````[sos,g] = cell2sos(cll)` also returns the scale gain `g`.```

## Examples

collapse all

Generate a 3-by-1 cell array of 1-by-2 cell arrays of 1-by-3 row vectors. Convert it to a matrix of second-order sections.

```cll = {{[3 6 7] [1 1 2]} {[1 4 5] [1 9 3]} {[2 7 1] [1 7 8]}}; sos = cell2sos(cll)```
```sos = 3×6 3 6 7 1 1 2 1 4 5 1 9 3 2 7 1 1 7 8 ```

## Input Arguments

collapse all

Second-order section cell-array representation, specified as a cell array.

For a filter system with L sections, specify `cll` using this structure:

• Cell array with L elements — For unity-gain filter systems. Each element of the cell array corresponds to a second-order section. The kth cell array element of `cll`

`cll{k} = {[b_0k b_1k b_2k] [1 a_1k a_2k]}`
contains the coefficients from the kth second-order-section of the filter system H(z):

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

• Cell array with L+1 elements — If the gain of the filter system is different from 1. The first element of `cll` contains the system gains at the numerator (gn) and at the denominator (gd). Then, the function appends each element of the cell array for the corresponding second-order section.

The first and the k+1th cell array element of `cll`

```cll{1} = {g_n g_d} cll{k+1} = {[b_0k b_1k b_2k] [1 a_1k a_2k]}```
contain the system gain and the coefficients from the kth second-order section of the filter system H(z), respectively, such that:

`$H\left(z\right)=g\prod _{k=1}^{L}{H}_{k}\left(z\right)=\frac{{g}_{n}}{{g}_{d}}\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: `cll = {{[2 4 2] [6 0 2]} {[3 3 0] [6 0 0]}}` specifies the second-order-section coefficients of a third-order Butterworth filter with normalized 3 dB frequency 0.5π rad/sample in the cell array format.

Example: `cll = {{7 5} {[2 4 2] [6 0 2]} {[3 3 0] [6 0 0]}}` specifies the second-order-section coefficients of a third-order Butterworth filter with normalized 3 dB frequency 0.5π rad/sample and scalar gain value of 7/5 = 1.4, represented in the cell array format.

Data Types: `double`
Complex Number Support: Yes

## Output Arguments

collapse all

Second-order section representation, returned 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}}.$`

Scale gain, returned as a scalar.

• If you specify `cll` as a cell array with L elements for a filter system with L sections, the `cell2sos` function returns `g` as `1`.

• If you specify `cll` as a cell array with L+1 elements for a filter system with L sections, the `cell2sos` function returns `g` as `g = g_n/g_d`, where `g_n` and `g_d` come from the first element of `cll`.

## Tips

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

## Version History

Introduced before R2006a