Main Content


Constrained-band equiripple FIR filter



b = fircband(n,f,a,w,c) designs filters having constrained error magnitudes (ripples) using the minimax filter design algorithm.

b = fircband(n,f,a,s) is used to design filters with special properties at certain frequency points specified by s.

b = fircband(___,'1') designs a type 1 filter (even-order symmetric). You can also specify type 2 (odd-order symmetric), type 3 (even-order antisymmetric), or type 4 (odd-order antisymmetric) filters. Note there are restrictions on a at f = 0 or f = 1 for types 2, 3, and 4.

b = fircband(___,'minphase') designs a minimum-phase FIR filter. You can also specify 'maxphase'.

b = fircband(___, 'check') produces a warning when there are potential transition-region anomalies in the filter response.

b = fircband(___,{lgrid}), where {lgrid} is a scalar cell array containing an integer, controls the density of the frequency grid.

[b,err] = fircband(___) returns the unweighted approximation error magnitudes. err has one element for each independent approximation error.

[b,err,res] = fircband(___) returns a structure res of optional results computed by fircband.


collapse all

Design a 12th-order lowpass filter with a constraint on the filter response.

b = fircband(12,[0 0.4 0.5 1], [1 1 0 0], ...
[1 0.2], {'w' 'c'});

View the response of the filter you designed.


Design two filters of different order with the stopband constrained to 60 dB. Use excess order (80) in the second filter to improve the passband ripple.

b1 = fircband(60,[0 .2 .25 1],[1 1 0 0],...
[1 .001],{'w','c'});
b2 = fircband(80,[0 .2 .25 1],[1 1 0 0],...
[1 .001],{'w','c'});
hfvt = filterAnalyzer(b1,1,b2,1);
setLegendStrings(hfvt,["Filter Order 60","Filter Order 80"]);

Input Arguments

collapse all

Filter order, specified as an integer greater than or equal to 3.

Normalized frequency points, specified as a real-valued vector. The argument must be in the range [0, 1] , where 1 corresponds to the Nyquist frequency. The number of elements in the vector is always a multiple of 2. The frequencies must be in increasing order.

Desired amplitudes at the points specified in f, specified as a vector. f and a must be of the same length. The length must be an even number.

Weights used to adjust the fit in each frequency band, specified as a real-valued vector. The length of w is half the length of f and a, so there is exactly one weight per band.

Constrained error magnitudes (ripples), specified as a cell array of character vectors or an array of strings. c must have the same length as w.

The entries of c must be either:

  • 'c' or "c" –– To indicate that the corresponding element in w is a constraint (the ripple for that band cannot exceed that value).

  • 'w' or "w" –– To indicate that the corresponding entry in w is a weight.

There must be at least one unconstrained band — c must contain at least one w entry. For instance, the Design a Constrained Lowpass Filter example uses a weight of 1 in the passband, and constrains the stopband ripple not to exceed 0.2 (about 14 dB).


If your constrained filter does not touch the constraints, increase the error weighting you apply to the unconstrained bands.


When you work with constrained stopbands, enter the stopband constraint according to the standard conversion formula for power — the resulting filter attenuation or constraint equals 20*log(constraint) where constraint is the value you enter in the function. For example, to set 20 dB of attenuation, use a value for the constraint equal to 0.1. This applies to constrained stopbands only.

Data Types: char | string

Special properties at certain frequency points, specified as a cell array of character vectors or an array of strings. s must have the same length as f and a. Entries of s must be one of:

  • 'n' or "n" — Normal frequency point.

  • 's' or "s" — Single-point band. The frequency “band” is given by a single point. Specify the corresponding gain at this frequency point in a.

  • 'f' or "f" — Forced frequency point. Forces the gain at the specified frequency band to be the value specified.

  • 'i' or "i" — Indeterminate frequency point. Use this argument when adjacent bands abut one another (no transition region).

Data Types: char | string

Control the density of the frequency grid, which has roughly (lgrid*n)/(2*bw) frequency points, where bw is the fraction of the total frequency band interval [0,1] covered by f. Increasing lgrid often results in filters that more exactly match an equiripple filter, but that take longer to compute. The default value of 16 is the minimum value that should be specified for lgrid.

Output Arguments

collapse all

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

The fircband uses the minimax filter design algorithm to design the following types of real FIR filters:

  • Types 1-4 linear phase

    • Type 1 is even order, symmetric

    • Type 2 is odd order, symmetric

    • Type 3 is even order, antisymmetric

    • Type 4 is odd order, antisymmetric

  • Minimum phase

  • Maximum phase

  • Minimum order (even or odd)

  • Extra ripple

  • Maximal ripple

  • Constrained ripple

  • Single-point band (notching and peaking)

  • Forced gain

  • Arbitrary shape frequency response curve filters

Unweighted approximation error magnitudes, returned as a scalar or a vector. err contains one element for each independent approximation error returned by the function.

Frequency response characteristics, returned as a structure. The structure res has the following fields:

Structure Field



Vector containing the frequency grid used in the filter design optimization


Desired response on fgrid


Weights on fgrid


Actual frequency response on the frequency grid


Error at each point (desired response - actual response) on the frequency grid


Vector of indices into fgrid of external frequencies


Vector of extremely frequencies


Filter order


Transition-region anomaly check. One element per band edge. Element values have the following meanings: 1 = OK , 0 = probable transition-region anomaly , -1 = edge not checked. Computed when you specify the 'check' input option in the function syntax.


Number of Remez iterations for the optimization


Number of function evaluations for the optimization

Version History

Introduced in R2011a

expand all

See Also

| | |