Main Content

fircls1

Constrained-least-squares linear-phase FIR lowpass and highpass filter design

    Description

    b = fircls1(n,wo,dp,ds) generates a length n + 1 linear-phase lowpass FIR filter b. The frequency-magnitude response of this filter match those given by the normalized cutoff frequency wo, passband ripple dp, and stopband ripple ds.

    b = fircls1(n,wo,dp,ds,wt) specifies a frequency wt so that the frequency-magnitude response of the filter falls within these intervals:

    • [1-dp,1+dp] along the passband region, if wt is in the passband region.

    • [-ds, ds] along the stopband region, if wt is in the stopband region.

    b = fircls1(n,wo,dp,ds,wp,ws,k) generates an FIR filter with an L2 weighting function specified by a passband edge frequency wp, a stopband edge frequency ws, and passband-to-stopband design error ratio k.

    b = fircls1(___,"high") designs a highpass FIR filter. The fircls1 function always uses an even filter order for the highpass configuration because the frequency response at the Nyquist frequency is 0 for odd orders. If you specify an odd-valued order n, fircls1 increments it by 1.

    b = fircls1(___,designDisplay) specifies visual display options for the filter design.

    example

    Examples

    collapse all

    Design a 55th-order lowpass filter with normalized cutoff frequency 0.3π rad/sample. Specify a passband ripple of 0.02 and a stopband ripple of 0.008. Display plots of the bands. The bound violations denote the iterations of the procedure as the design converges.

    n = 55;
    wo = 0.3;
    dp = 0.02;
    ds = 0.008;
    b = fircls1(n,wo,dp,ds,"both");
        Bound Violation = 0.0870385343920  
        Bound Violation = 0.0149343456540  
        Bound Violation = 0.0056513587932  
        Bound Violation = 0.0001056264205  
        Bound Violation = 0.0000967624352  
        Bound Violation = 0.0000000226538  
        Bound Violation = 0.0000000000038  
    

    Figure contains 3 axes objects. Axes object 1 contains 2 objects of type line. One or more of the lines displays its values using only markers Axes object 2 contains 2 objects of type line. One or more of the lines displays its values using only markers Axes object 3 contains 2 objects of type line. One or more of the lines displays its values using only markers

    Input Arguments

    collapse all

    Filter order, specified as a real-valued positive integer scalar.

    Data Types: single | double

    Normalized cutoff frequency, specified as a real-valued positive scalar between 0 and 1, where 1 corresponds to the Nyquist frequency.

    Data Types: single | double

    Passband ripple, specified as a real-valued positive scalar. The passband ripple is the maximum passband deviation from 1.

    Note

    When designing very narrow-band filters with small dp, a filter of the specified order that meets the specifications might not exist. In this scenario, the function returns a filter design with frequency-magnitude characteristics that are as close to the specifications as possible. To overcome this problem, relax the design constraints or increase the filter order.

    Data Types: single | double

    Stopband ripple, specified as a real-valued positive scalar. The stopband ripple is the maximum stopband deviation from 0.

    Note

    When designing very narrow-band filters with small ds, a filter of the specified order that meets the specifications might not exist. In this scenario, the function returns a filter design with frequency-magnitude characteristics that are as close to the specifications as possible. To overcome this problem, relax the design constraints or increase the filter order.

    Data Types: single | double

    Normalized band edge frequency, specified as a real-valued positive scalar between 0 and 1, where 1 corresponds to the Nyquist frequency.

    Specifying a normalized band edge frequency can help you create one of these four filter designs that meet a passband or stopband edge requirement:

    • Lowpass FIR filter:

      • 0 < wt < wo < 1 — The amplitude of the filter is within dp of 1 over the frequency range 0 < ω < wt.

      • 0 < wo < wt < 1 — The amplitude of the filter is within ds of 0 over the frequency range wt < ω < 1.

    • Highpass FIR filter:

      • 0 < wt < wo < 1 — The amplitude of the filter is within ds of 0 over the frequency range 0 < ω < wt.

      • 0 < wo < wt < 1 — The amplitude of the filter is within dp of 1 over the frequency range wt < ω < 1.

    Data Types: single | double

    Passband edge frequency of the L2 weighting function, specified as a real-valued scalar. The value of wp must lie in the passband edge:

    • wp<wo for lowpass filters.

    • wp>wo for highpass filters.

    Considering the actual and desired frequency response magnitudes A(ω) and D(ω), respectively, the passband design L2 error is

    • ep=0wp|A(ω)D(ω)|2dω for lowpass filters.

    • ep=wpπ|A(ω)D(ω)|2dω for highpass filters.

    Data Types: single | double

    Stopband edge frequency of the L2 weighting function, specified as a real-valued scalar. The value of wp must lie in the stopband edge:

    • ws>wo for lowpass filters.

    • ws<wo for highpass filters.

    Considering the actual and desired frequency response magnitudes A(ω) and D(ω), respectively, the stopband design L2 error is

    • es=wsπ|A(ω)D(ω)|2dω for lowpass filters.

    • es=0ws|A(ω)D(ω)|2dω for highpass filters.

    Data Types: single | double

    Passband-to-stopband design L2 error ratio, specified as a real-valued scalar. Considering the passband and stopband design L2 errors ep and es from the edge frequencies wp and ws, respectively, the value of k is:

    k=epes

    Data Types: single | double

    Filter design display options, specified as one of the following:

    • "trace" — View a textual display of the design error at each iteration step.

    • "plots" — View a collection of plots showing the full-band magnitude response of the filter and a zoomed view of the magnitude response in each sub-band. The function updates all plots at each iteration step. The Os on the plot are the estimated extrema of the new iteration and the Xs are the estimated extrema of the previous iteration, where the extrema are the peaks (maxima and minima) of the filter ripples.

    • "both" — View both a textual display and plots.

    Data Types: char | string

    Output Arguments

    collapse all

    Filter coefficients, returned as a row vector of length n + 1.

    Algorithms

    The fircls1 function uses an iterative least-squares algorithm to obtain an equiripple response. The algorithm is a multiple exchange algorithm that uses Lagrange multipliers and Kuhn-Tucker conditions on each iteration.

    References

    [1] Selesnick, I. W., M. Lang, and C. S. Burrus. “Constrained Least Square Design of FIR Filters without Specified Transition Bands.” Proceedings of the 1995 International Conference on Acoustics, Speech, and Signal Processing. Vol. 2, 1995, pp. 1260–1263.

    [2] Selesnick, I. W., M. Lang, and C. S. Burrus. “Constrained Least Square Design of FIR Filters without Specified Transition Bands.” IEEE® Transactions on Signal Processing. Vol. 44, Number 8, 1996, pp. 1879–1892.

    Extended Capabilities

    Version History

    Introduced before R2006a

    See Also

    | |