# sos2ctf

Convert digital filter second-order section parameters to cascaded transfer function form

Since R2024a

## Syntax

``[b,a] = sos2ctf(sos)``
``[b,a] = sos2ctf(sos,g)``

## Description

example

````[b,a] = sos2ctf(sos)` computes the cascaded transfer function of the filter system described by the second-order section matrix `sos`.```

example

````[b,a] = sos2ctf(sos,g)` also specifies the scale values `g` to perform gain scaling across the sections of the cascaded transfer function of the system.```

## Examples

collapse all

Convert a second-order sections matrix to the cascaded transfer function form.

```sos = [2 4 2 1 0 0;3 2 0 1 1 0]; [ctfB,ctfA] = sos2ctf(sos)```
```ctfB = 2×3 2 4 2 3 2 0 ```
```ctfA = 2×3 1 0 0 1 1 0 ```

Obtain the cascaded transfer function of a 10th-order lowpass elliptic filter with a normalized cutoff frequency of 0.25$\pi$rad/sample.

```[z,p,k] = ellip(10,1,60,0.25); [sos,g] = zp2sos(z,p,k); [b,a] = sos2ctf(sos,g)```
```b = 5×3 0.3216 0.2716 0.3216 0.3216 -0.2850 0.3216 0.3216 -0.4033 0.3216 0.3216 -0.4345 0.3216 0.3216 -0.4432 0.3216 ```
```a = 5×3 1.0000 -1.5959 0.6751 1.0000 -1.5123 0.8125 1.0000 -1.4458 0.9225 1.0000 -1.4169 0.9730 1.0000 -1.4099 0.9936 ```

Plot the filter response.

`filterAnalyzer(b,a)`

## Input Arguments

collapse all

Second-order section 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 values, specified as a real-valued scalar or as a real-valued vector with L+1 elements, where L is the number of second-order sections.

The `sos2ctf` function applies a gain to the filter sections using the `scaleFilterSections` function. Depending on the value you specify in `g`:

• Scalar — The function uniformly distributes the gain across all filter sections.

• Vector — The function applies the first L gain values to the corresponding filter sections and distributes the last gain value uniformly across all filter sections.

## Output Arguments

collapse all

Cascaded transfer function coefficients, returned as L-by-3 matrices, where L is the number of second-order sections.

The matrices `b` and `a` list the numerator and denominator coefficients of the cascaded transfer function, respectively. See Cascaded Transfer Functions for more information.

collapse all

Partitioning a filter system into sections connected in cascade form offers several advantages, such as easy design, less susceptibility to coefficient quantization errors, and improved stability [1]. A filter system H(z) can be expressed in L sectional transfer functions H1(z), H2(z), …, HL(z), where

`$H\left(z\right)=\prod _{k=1}^{L}{H}_{k}\left(z\right)\text{.}$`

The `sos2ctf` computes the numerator and denominator coefficients of the cascaded-transfer-function sections from the second-order-section coefficients of the filter system.

The output arguments `b` and `a` associate with the matrices

`$b=\left[\begin{array}{ccc}{{b}^{\prime }}_{01}& {{b}^{\prime }}_{11}& {{b}^{\prime }}_{21}\\ {{b}^{\prime }}_{02}& {{b}^{\prime }}_{12}& {{b}^{\prime }}_{22}\\ ⋮& ⋮& ⋮\\ {{b}^{\prime }}_{0L}& {{b}^{\prime }}_{1L}& {{b}^{\prime }}_{2L}\end{array}\right]$`

and $\text{a}=\left[\begin{array}{ccc}1& {a}_{11}& {a}_{21}\\ 1& {a}_{12}& {a}_{22}\\ ⋮& ⋮& ⋮\\ 1& {a}_{1L}& {a}_{2L}\end{array}\right]$.

These matrices contain the second-order cascaded transfer function coefficients of H(z)

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

## References

[1] Parks, Thomas W., and C. Sidney Burrus. Digital Filter Design. Hoboken, NJ: John Wiley & Sons, 1987, pp. 233–239.

## Version History

Introduced in R2024a