Engee documentation

sos2cell

Transformation of a matrix of second-order sections into a vector of any type.

Library

EngeeDSP

Syntax

Function call

  • cll = sos2cell(sos) — generates a vector of any type cll, containing the coefficients of a filter system described by a matrix of second-order sections sos.

  • cll = sos2cell(sos,g) — also sets the scale gain g to add any type of vector to the representation cll the system specified in the argument sos.

Arguments

Input arguments

# sos — representation of second-order sections

+ the matrix

Details

The representation of the second-order sections, defined as a matrix. Argument sos — this is a matrix of size , where — number of second-order sections:

the rows of which contain the coefficients of the numerator and denominator and second-order sections of the function :

Типы данных

Float32, Float64

Support for complex numbers

Yes

# g — scale gain factor

+ 1 (default) | scalar

Details

The scale gain factor, set as a scalar.

Типы данных

Float32, Float64

Support for complex numbers

Yes

Output arguments

# cll — representation of second-order sections as a vector of any type

+ vector of type Any

Details

The representation of the second-order sections returned as a two-element vector of the type Any the following length:

  • elements — if the value of the argument is g equally 1 or if it is not set. Each element of a vector of any type corresponds to a second-order section. For example, the vector element cll[k] contains coefficients from -th section of the matrix sos.

    cll[k] = [sos(k, 1:3) sos(k, 4:6)]
  • element — if the value of the argument is g different from 1. The first element of the vector cll contains the gain factor specified in the argument g. Each subsequent element of a vector of any type corresponds to a second-order section. For example, the vector element cll[k+1] contains coefficients from -th section of the matrix sos.

    cll[1] = [g 1]
    cll[k+1] = [sos(k, 1:3) sos(k, 4:6)]

Examples

Vector of second-order sections of an elliptical filter

Details

Let’s create an elliptical low-pass filter. 4-th order with ripples in the bandwidth 0.5 dB and attenuation in the boom band 20 dB. The bandwidth limit is 0.6 from the Nyquist frequency. We transform the transfer function into a matrix of sections of the second order.

import EngeeDSP.Functions: ellip, tf2sos

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

Using the function sos2cell to convert a matrix of size 2 on 6 obtained using the function tf2sos, into a vector of any type c size 1 on 2. Let’s display the second element of the first element of the vector c. Let’s make sure that it contains the coefficients of the denominator of the first section of the second order matrix. m.

c = sos2cell(m)
compare = [c[1][2]; m[1, 4:6]']
2×3 Matrix{Float64}:
 1.0  0.167735  0.257534
 1.0  0.167735  0.257534