<< Chapter < Page Chapter >> Page >

Matlab programs

A Matlab program for designing multiband FIR filters using the weighted least squares approximation described in [link] and [link] above is included in the Appendix. The program assumes passbands and stopbandsthat alternate with transition bands. The passbands are assumed to have constant gain for simplicity but that could be generalized with theresults from FIR Digital Filters . The first for loop constructs the h ^ w ( n ) in [link] by sequentially designing weighted bandpass filters and a separately weighted transition band similar to the examplein [link] . These are added together in this loop to give the vector h w in [link] . The second for loop constructs the C matrix in [link] using the formula [link] . Care must be taken to correctly calculate the indeterminate values of sinc(0) and to properlyinclude the effects of ω F = π .

When one uses zero weights in the transition bands, the C matrix becomes ill conditioned when the product of the filter length N and the sum of the transition band widths in Hertz is much above 12. This is anapproximate rule which is somewhat affected by different passband and stopband weights, but it gives an indication of when numerical problemswill occur. To reduce this problem, the program includes optimal spline transition functions so that a small weight can be used to improve theconditioning of C with minimal effect on the optimality of the approximation.

Examples

To illustrate the effects of using a weighted least squared error design criterion, a simple length-21 linear phase lowpass FIR filter wasdesigned, with unity weighting in the pass and stop bands and zero weighting in the transition band. The frequency response is shown in [link] a. The same filter is designed with a weight of 100 in the passband and the response is shown in [link] b and the case for a weight of 100 in the stopband is shown in [link] c. It is instructive to design many example filters and observe the effectsof different weights, use of spline vs zero weight transition bands, and the effects of the transition band width on the pass and stopbandperformance.

This figure consist three graphs. The first graph is labeled Length-21 Lowpass FIR Filter Response, Least Squared error. It consist of a line extending to the right of the y axis and then intersecting another line that rises from the x axis. The lines along with the x and y axis form a rectangle. A wave form begins at the top of the rectangle. The wave wavers a little along the top of the rectangle and then falls to the x axis where is wavers as it makes it way to the left of the graph. The second graph is labeled Length 21 Weighted Passband Lowpass FIR Filter Response. The graph is essentially the same as the previous graph except for the absence of the rectangle and the waver of the wave along the x axis is much more pronounce. The third graph is labeled Length 21 Weighted Stopband Lowpass FIR Filter Response. This graph is similar to the previous to, but with this graph the waver of the initial segment is more pronounced and the waver of the section along the x axis is nearly non existent.
Frequency Response of Length-21 FIR Filter Designed by Weighted Least Squared Error

The same specifications that were used in the design using optimal spline transition functions of [link] a is used in the design here with unity weights in the stop and passbands and zero weights in thetransition bands. The result is fairly similar to the spline function design and is shown in [link] a for N = 51 . For lengths above around 131, numerical errors resulted in erratic performance in thetransition bands. Indeed for this case, the use of the spline method would probably be superior. The advantage of the weighted least squares methodis illustrated in [link] b where the same specifications are used but with a weight of 100 in the first passband, in [link] c where a weight of 100 is used in the second passband, and in [link] d where a weight of 100 is used in the third passband. This use of weights is impossible using the spline method or anywindowing method.

This figure consist of four graphs. The top left graph is labeled Length-51 Multiband FIR Filter. It consist of a waveform that starts along the x axis with a slight waver and the shoots up almost vertically to about y=.7 where the wave wavers until it drops slightly to about y=.5 wavers a little and falls back to the x axis wavers a little and shoots all the back up to about y=1. The second graph labeled Length-51 Weighted Multiband FIR Filter progresses exactly the same way as the previous graph wave, but the first upper wavering area is actually smooth and flat in this graph. There is an arrow pointing to this section labeling it as weighted. The bottom left graph is labeled Length-51 Weighted Multiband FIR Filter and it also progresses the same way as the previous two graph except the second area of wavering is smoothed and flat and labeled with and arrow as weighted. The final graph the bottom right is the same except the last and highest portion is now flat and smooth and marked as weighted with an arrow.
Frequency Response of Length-15 FIR Filter Designed by Least Squared Error

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing and digital filter design (draft). OpenStax CNX. Nov 17, 2012 Download for free at http://cnx.org/content/col10598/1.6
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing and digital filter design (draft)' conversation and receive update notifications?

Ask