主要内容

iirlp2hp

Transform IIR lowpass filter to IIR highpass filter

Description

[num,den] = iirlp2hp(b,a,wo,wt) transforms an IIR lowpass filter to an IIR highpass filter.

The iirlp2hp function returns the numerator and denominator coefficients of the transformed highpass filter. The function accepts wo, frequency value to be transformed from the prototype filter, and wt, desired frequency in the transformed highpass filter, and applies the lowpass to highpass frequency transformation on the input prototype filter. The input prototype lowpass filter is specified with the numerator and denominator coefficients, b and a respectively. For more details on the transformation, see IIR Lowpass to Highpass Frequency Transformation.

example

[num,den,allpassNum,allpassDen] = iirlp2hp(b,a,wo,wt) additionally returns the numerator and the denominator coefficients of the mapping filter.

[tfiltObj,allpassNum,allpassDen] = iirlp2hp(pfiltObj,wo,wt) specifies the input prototype lowpass IIR filter as a filter object. The function returns the target highpass IIR filter as a filter object. (since R2026a)

example

Examples

collapse all

Design an IIR lowpass filter using the iirlpnorm function. Transform the filter to highpass by moving the magnitude response at one frequency in the source filter to a new location in the transformed filter.

Input IIR lowpass Filter

Generate a least P-norm optimal IIR lowpass filter with varying attenuation levels in the stopband. Specify a numerator order of 10 and a denominator order of 6. The function returns the coefficients both in the vector form and in the second-order sections (SOS) form. The output argument g specifies the overall gain of the filter when expressed in the second-order sections form.

[b,a,~,sos,g] = iirlpnorm(10,6,[0 0.0175 0.02 0.0215 0.025 1], ...
    [0 0.0175 0.02 0.0215 0.025 1],[1 1 0 0 0 0], ...
    [1 1 1 1 20 20]);

Visualize the magnitude response of the filter.

filterAnalyzer(b,a)

Transform Filter Using iirlp2hp

Transform the IIR lowpass filter using the iirlp2hp function. Specify the filter as a vector of numerator and denominator coefficients.

To generate a highpass filter whose passband flattens out at 0.4π rad/sample, select the frequency in the lowpass filter at 0.0175π, the frequency where the passband starts to roll off, and move it to the new location.

wc = 0.0175;
wd = 0.4;
[num,den] = iirlp2hp(b,a,wc,wd);

Compare the magnitude responses of the filters. The transition band for the highpass filter is essentially the mirror image of the transition for the lowpass filter from 0.0175π to 0.025π, stretched out over a wider frequency range. In the passbands, the filters share common ripple characteristics and magnitude.

filterAnalyzer(b,a,num,den,...
    FilterNames=["PrototypeFilter_TFForm",...
    "TransformedHighpassFilter"])

Alternatively, you can also specify the input IIR lowpass filter as a matrix of coefficients. Pass the scaled second order section coefficient matrices as inputs. Apply the scaling factor g to the first section of the filter.

sosg = sos;
sosg(1,1:3) = g*sosg(1,1:3);
[num2,den2] = iirlp2hp(sosg(:,1:3),sosg(:,4:6),wc,wd);

Use the sos2ctf function to convert the second-order section matrices to the cascaded transfer function form.

[b_ctf,a_ctf] = sos2ctf(sosg);

Compare the magnitude response of the filters.

filterAnalyzer(b_ctf,a_ctf,num2,den2,...
    FilterNames=["PrototypeFilterFromSOSMatrix",...
    "TransformedHighpassFilterFromSOSMatrix"])

Since R2026a

Design and implement an IIR lowpass filter object using the designLowpassIIR function. The function returns a dsp.SOSFilter object when you set the SystemObject argument to true.

psosFilt = designLowpassIIR(FilterOrder=30,HalfPowerFrequency=0.5,DesignMethod="butter",...
        SystemObject=true)
psosFilt = 
  dsp.SOSFilter with properties:

            Structure: 'Direct form II transposed'
    CoefficientSource: 'Property'
            Numerator: [15×3 double]
          Denominator: [15×3 double]
       HasScaleValues: false

  Show all properties

Create a dsp.DynamicFilterVisualizer object to visualize the magnitude response of the filter.

filterViz = dsp.DynamicFilterVisualizer(NormalizedFrequency=true,YLimits=[-80 20]);
filterViz(psosFilt)

Transform the IIR lowpass filter to an IIR highpass filter using the iirlp2hp function. Specify the function to transform 0.3π rad/sample in the prototype filter to 0.7π rad/sample in the target filter. The function implements the highpass filter as a dsp.SOSFilter object.

tsosFilt = iirlp2hp(psosFilt,0.3,0.7)
tsosFilt = 
  dsp.SOSFilter with properties:

            Structure: 'Direct form II transposed'
    CoefficientSource: 'Property'
            Numerator: [15×3 double]
          Denominator: [15×3 double]
       HasScaleValues: false

  Show all properties

Visualize the magnitude response of the transformed IIR highpass filter.

filterViz(tsosFilt)

Input Arguments

collapse all

Numerator coefficients of the prototype lowpass IIR filter, specified as either:

  • Row vector –– Specifies the values of [b0, b1, …, bn], given this transfer function form:

    H(z)=B(z)A(z)=b0+b1z1++bnzna0+a1z1++anzn,

    where n is the order of the filter.

  • Matrix –– Specifies the numerator coefficients in the form of an P-by-(Q+1) matrix, where P is the number of filter sections and Q is the order of each filter section. If Q = 2, the filter is a second-order section filter. For higher-order sections, make Q > 2.

    b=[b01b11b21...bQ1b02b12b22...bQ2b0Pb1Pb2PbQP]

    In the transfer function form, the numerator coefficient matrix bik of the IIR filter can be represented using the following equation:

    H(z)=k=1PHk(z)=k=1Pb0k+b1kz1+b2kz2++bQkzQa0k+a1kz1+a2kz2++aQkzQ,

    where,

    • a –– Denominator coefficients matrix. For more information on how to specify this matrix, see a.

    • k –– Row index.

    • i –– Column index.

    When specified in the matrix form, b and a matrices must have the same number of rows (filter sections) Q.

Data Types: single | double
Complex Number Support: Yes

Denominator coefficients for a prototype lowpass IIR filter, specified as one of these options:

  • Row vector –– Specifies the values of [a0, a1, …, an], given this transfer function form:

    H(z)=B(z)A(z)=b0+b1z1++bnzna0+a1z1++anzn,

    where n is the order of the filter.

  • Matrix –– Specifies the denominator coefficients in the form of an P-by-(Q+1) matrix, where P is the number of filter sections and Q is the order of each filter section. If Q = 2, the filter is a second-order section filter. For higher-order sections, make Q > 2.

    a=[a01a11a21aQ1a02a12a22aQ2a0Pa1Pa2PaQP]

    In the transfer function form, the denominator coefficient matrix aik of the IIR filter can be represented using the following equation:

    H(z)=k=1PHk(z)=k=1Pb0k+b1kz1+b2kz2++bQkzQa0k+a1kz1+a2kz2++aQkzQ,

    where,

    • b –– Numerator coefficients matrix. For more information on how to specify this matrix, see b.

    • k –– Row index.

    • i –– Column index.

    When specified in the matrix form, a and b matrices must have the same number of rows (filter sections) P.

Data Types: single | double
Complex Number Support: Yes

Since R2026a

Prototype lowpass IIR filter, specified as one of these filter objects:

Frequency value to transform from the prototype filter, specified as a real positive scalar in the range (0, 1).

Data Types: single | double

Desired frequency location in the transformed highpass filter, specified as a real positive scalar in the range (0, 1).

Data Types: single | double

Output Arguments

collapse all

Numerator coefficients of the transformed highpass filter, returned as one of the following:

  • Row vector of length n+1, where n is the order of the input filter. The num output is a row vector when the input coefficients b and a are row vectors.

  • P-by-(Q+1) matrix, where P is the number of filter sections and Q is the order of each section of the transformed filter. The num output is a matrix when the input coefficients b and a are matrices.

Data Types: single | double
Complex Number Support: Yes

Denominator coefficients of the transformed highpass filter, returned as one of the following:

  • Row vector of length n+1, where n is the order of the input filter. The den output is a row vector when the input coefficients b and a are row vectors.

  • P-by-(Q+1) matrix, where P is the number of filter sections and Q is the order of each section of the transformed filter. The den output is a matrix when the input coefficients b and a are matrices.

Data Types: single | double

Since R2026a

Target highpass IIR filter, returned as one of these filter objects:

Numerator coefficients of the mapping filter, returned as a row vector.

Data Types: single | double

Denominator coefficients of the mapping filter, returned as a row vector.

Data Types: single | double

More About

collapse all

References

[1] Nowrouzian, B., and A.G. Constantinides. “Prototype Reference Transfer Function Parameters in the Discrete-Time Frequency Transformations.” In Proceedings of the 33rd Midwest Symposium on Circuits and Systems, 1078–82. Calgary, Alta., Canada: IEEE, 1991. https://doi.org/10.1109/MWSCAS.1990.140912.

[2] Nowrouzian, B., and L.T. Bruton. “Closed-Form Solutions for Discrete-Time Elliptic Transfer Functions.” In [1992] Proceedings of the 35th Midwest Symposium on Circuits and Systems, 784–87. Washington, DC, USA: IEEE, 1992. https://doi.org/10.1109/MWSCAS.1992.271206.

[3] Constantinides, A.G.“Spectral transformations for digital filters.” Proceedings of the IEEE, vol. 117, no. 8: 1585-1590. August 1970.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2011a

expand all

See Also

Functions