Main Content

scaleFilterSections

Scale cascaded transfer functions with scale values

Since R2023b

Description

Bg = scaleFilterSections(B,g) scales the sections of the numerator filter coefficients B represented with Cascaded Transfer Functions (CTF) by applying the scale values specified in g.

example

Examples

collapse all

Design a 14th-order elliptic bandpass digital filter with a lower passband frequency of π/5 rad/sample and a higher passband frequency of 3π/5 rad/sample. Specify 10 dB of passband ripple and 40 dB of stopband attenuation. Represent the filter using cascaded transfer functions.

N = 14;
[B,A] = ellip(N/2,10,40,[0.2 0.6],"ctf")
B = 4×5

    0.4184    0.0000   -0.4184         0         0
    0.4184   -0.3351    0.1684   -0.3351    0.4184
    0.4184   -0.4070    0.3842   -0.4070    0.4184
    0.4184   -0.4158    0.4107   -0.4158    0.4184

A = 4×5

    1.0000   -0.7094    0.8572         0         0
    1.0000   -1.1435    1.4172   -1.0733    0.9081
    1.0000   -1.0196    1.0568   -1.0091    0.9862
    1.0000   -1.0010    1.0029   -0.9998    0.9984

Define scale values as a vector with incremental gains (1, 2, ..., L) for each of the L sections, and append the overall system gain as 0.5L. This vector makes the numerator coefficients be scaled by 0.5, 1, ..., 0.5L.

numSections = size(B,1);
g = [1:numSections 0.5^(numSections)];

Use scaleFilterSections to scale the filter numerator coefficients so that the gain is uniformly distributed across all sections.

Bg = scaleFilterSections(B,g)
Bg = 4×5

    0.2092    0.0000   -0.2092         0         0
    0.4184   -0.3351    0.1684   -0.3351    0.4184
    0.6276   -0.6105    0.5764   -0.6105    0.6276
    0.8367   -0.8317    0.8215   -0.8317    0.8367

Visualize the frequency response.

freqz(Bg,A,4096,"ctf")

Figure contains 2 axes objects. Axes object 1 with title Phase, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Phase (degrees) contains an object of type line. Axes object 2 with title Magnitude, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Magnitude (dB) contains an object of type line.

Input Arguments

collapse all

Unscaled CTF numerator filter coefficients, specified as a matrix.

  • The number of rows in B equals L, where L is the number of filter sections in the cascade.

  • The number of columns in B equals m + 1, where m is the section order.

  • If you specify B as a vector, scaleFilterSections treats B as a matrix, determining the number of sections and the numerator order depending on vector size:

    • Row vector — The function treats B as a one-section transfer function with numerator order m, where m + 1 is the number of columns. The ith column of B corresponds to the z-(i - 1) numerator coefficient.

    • Column vector — The function treats B as an L-section transfer function with scalar numerators. Each row of B corresponds to a numerator in each corresponding section.

Data Types: single | double
Complex Number Support: Yes

Scale values, specified as a scalar or a vector with L + 1 elements, where L is the number of filter sections in the cascade.

  • If g is a scalar, scaleFilterSections applies the value uniformly to all the cascade filter sections.

  • If g is a vector, scaleFilterSections applies each of the first L scale values to the corresponding filter section and the last scale value uniformly to all the filter sections.

Data Types: single | double

Output Arguments

collapse all

Scaled CTF numerator filter coefficients, returned as a matrix of the same size as B.

See Algorithms for more information.

More About

collapse all

Cascaded Transfer Functions

Partitioning an IIR digital filter into cascaded sections improves its numerical stability and reduces its susceptibility to coefficient quantization errors. The cascaded form of a transfer function H(z) in terms of the L transfer functions H1(z), H2(z), …, HL(z) is

H(z)=l=1LHl(z)=H1(z)×H2(z)××HL(z).

Algorithms

The scaleFilterSections function scales the matrix B with a scalar or vector g and returns Bg as one of these:

  • If g is a scalar:

    L = size(B,1);
    gL = (abs(g))^(1/L);
    Bg = B*gL;
    Bg(L,:) = sign(g)*Bg(L,:);

  • If g is a vector with L+1 samples, given L sections:

    L = size(B,1);
    gS = g(end);
    gL = (abs(gS))^(1/L);
    gl = g(1:end-1);
    Bg = B.*gl(:)*gL;
    Bg(L,:) = sign(gS)*Bg(L,:);

References

[1] Lyons, Richard G. Understanding Digital Signal Processing. Upper Saddle River, NJ: Prentice Hall, 2004.

Version History

Introduced in R2023b

See Also

Functions