Signal Processing Toolbox | ![]() ![]() |
Constrained Least Squares FIR Filter Design
The Constrained Least Squares (CLS) FIR filter design functions implement a technique that enables you to design FIR filters without explicitly defining the transition bands for the magnitude response. The ability to omit the specification of transition bands is useful in several situations. For example, it may not be clear where a rigidly defined transition band should appear if noise and signal information appear together in the same frequency band. Similarly, it may make sense to omit the specification of transition bands if they appear only to control the results of Gibbs phenomena that appear in the filter's response. See Selesnick, Lang, and Burrus [2] for discussion of this method.
Instead of defining passbands, stopbands, and transition regions, the CLS method accepts a cutoff frequency (for the highpass, lowpass, bandpass, or bandstop cases), or passband and stopband edges (for multiband cases), for the desired response. In this way, the CLS method defines transition regions implicitly, rather than explicitly.
The key feature of the CLS method is that it enables you to define upper and lower thresholds that contain the maximum allowable ripple in the magnitude response. Given this constraint, the technique applies the least square error minimization technique over the frequency range of the filter's response, instead of over specific bands. The error minimization includes any areas of discontinuity in the ideal, "brick wall" response. An additional benefit is that the technique enables you to specify arbitrarily small peaks resulting from Gibbs' phenomena.
There are two toolbox functions that implement this design technique.
Description |
Function |
Constrained least square multiband FIR filter design |
|
Constrained least square filter design for lowpass and highpass linear phase filters |
|
For details on the calling syntax for these functions, see their reference descriptions in the Function Reference.
Basic Lowpass and Highpass CLS Filter Design
The most basic of the CLS design functions, fircls1
, uses this technique to design lowpass and highpass FIR filters. As an example, consider designing a filter with order 61 impulse response and cutoff frequency of 0.3 (normalized). Further, define the upper and lower bounds that constrain the design process as:
To approach this design problem using fircls1
, use the following commands:
Note that the y-axis shown below is in Magnitude Squared. You can set this by right-clicking on the axis label and selecting Magnitude Squared from the menu.
Multiband CLS Filter Design
fircls
uses the same technique to design FIR filters with a desired piecewise constant magnitude response. In this case, you can specify a vector of band edges and a corresponding vector of band amplitudes. In addition, you can specify the maximum amount of ripple for each band.
For example, assume the specifications for a filter call for:
Design a CLS filter with impulse response order 129 that meets these specifications:
n = 129; f = [0 0.3 0.5 0.7 0.9 1]; a = [0 0.5 0 1 0]; up = [0.005 0.51 0.03 1.02 0.05]; lo = [-0.005 0.49 -0.03 0.98 -0.05]; h = fircls(n,f,a,up,lo); fvtool(h,1)
Note that the y-axis shown below is in Magnitude Squared. You can set this by right-clicking on the axis label and selecting Magnitude Squared from the menu.
Weighted CLS Filter Design
Weighted CLS filter design lets you design lowpass or highpass FIR filters with relative weighting of the error minimization in each band. The fircls1
function enables you to specify the passband and stopband edges for the least squares weighting function, as well as a constant k
that specifies the ratio of the stopband to passband weighting.
For example, consider specifications that call for an FIR filter with impulse response order of 55 and cutoff frequency of 0.3 (normalized). Also assume maximum allowable passband ripple of 0.02 and maximum allowable stopband ripple of 0.004. In addition, add weighting requirements:
To approach this using fircls1
, type
n = 55; wo = 0.3; dp = 0.02; ds = 0.004; wp = 0.28; ws = 0.32; k = 10; h = fircls1(n,wo,dp,ds,wp,ws,k); fvtool(h,1)
Note that the y-axis shown below is in Magnitude Squared. You can set this by right-clicking on the axis label and selecting Magnitude Squared from the menu.
![]() | Multiband FIR Filter Design with Transition Bands | Arbitrary-Response Filter Design | ![]() |
© 1994-2005 The MathWorks, Inc.