Filter Design Toolbox 4.6
Arbitrary Magnitude Filter Design
The filter design (FDESIGN) objects are a collection of objects that allow for the design of filters with various types of responses. Among those types, the arbitrary magnitude is the less specialized and most versatile one. The examples below illustrate how the arbitrary magnitude design can solve problems when the other response type find their limits.
Contents
FIR Modeling with the Frequency Sampling Method
This section illustrates cases where the amplitude of the filter is defined on the complete Nyquist range (there is no relaxed or "don't care" regions), we use a single (full) band specification type and the robust frequency sampling algorithm. Let's imagine a filter whose amplitude would be defined by three sections: a sinusoidal section, a piecewise linear section and a quadratic section. The shape of this filter being quite complicated, it is necessary to select a large filter order:
N = 300; B1 = 0:0.01:0.18; B2 = [.2 .38 .4 .55 .562 .585 .6 .78]; B3 = [0.79:0.01:1]; A1 = .5+sin(2*pi*7.5*B1)/4; % Sinusoidal section A2 = [.5 2.3 1 1 -.2 -.2 1 1]; % Piecewise linear section A3 = .2+18*(1-B3).^2; % Quadratic section F = [B1 B2 B3]; A = [A1 A2 A3]; d = fdesign.arbmag('N,F,A',N,F,A); Hd = design(d,'freqsamp'); fvtool(Hd,'MagnitudeDisplay','Zero-phase','DesignMask','on') set(gcf,'Color','white')
close(gcf)
In this first example, the normalized frequency points were distributed between 0 and 1 (extrema included). When we specify negative frequencies, the resulting filter is complex. Next, we model a complex RF bandpass filter. Notice the use of a Kaiser window to mitigate the effects of the Gibbs phenomenon that occurs due to the gap between the value at -pi and that at pi of 70 dB:
load cfir.mat; N = 200; d = fdesign.arbmag('N,F,A',N,F,A); design(d,'freqsamp', 'window' ,{@kaiser,20}); set(gcf,'Color','white')
close(gcf)
Modeling Smooth Functions with an Equiripple FIR Filter
The equiripple algorithm is well suited to model smooth functions. In this example, we model an exponential with a 30th order FIR filter. We increase the weights proportionally to the desired amplitude to get better performance at high frequencies:
F = linspace(0,1,100); A = exp(-2*pi*F); W = .1-20*log10(abs(A)); N = 30; d = fdesign.arbmag('N,F,A',N,F,A); Hd = design(d,'equiripple','weights',W); fvtool(Hd,'MagnitudeDisplay','Zero-phase','DesignMask','on') set(gcf,'Color','white')
close(gcf)
Single-Band vs Multi-Band Equiripple FIR Designs
In certain applications, it is sometimes interesting to shape the stopband of the filter to minimize the integrated side-lobes levels or to improve quantization robustness for example. To design a lowpass filter with a staircase stopband, we use a distribution of weights that will increase the attenuation of each step by 5dB:
N = 150; F = [0 .25 .3 .4 .401 .5 .501 .6 .601 .7 .701 .8 .801 .9 .901 1]; A = [1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; W = 10.^([0 0 5 5 10 10 15 15 20 20 25 25 30 30 35 35]/20); d = fdesign.arbmag('N,F,A',N,F,A); Hd = design(d,'equiripple','weights',W);
As an alternative, let's use a multi-band approach by defining two bands (passband and stopband) separated by a "don't care" region (or transition band):
B = 2; % Number of bands F1 = F(1:2); % Passband F2 = F(3:end); % Stopband % F(2:3)=[.25 .3] % Transition band A1 = A(1:2); A2 = A(3:end); W1 = W(1:2); W2 = W(3:end); d = fdesign.arbmag('N,B,F,A',N,B,F1,A1,F2,A2); Hd(2) = design(d,'equiripple','B1Weights',W1,'B2Weights',W2); hfvt = fvtool(Hd); legend(hfvt, 'Single-Band Design', 'Multi-Band Design'); set(gcf,'Color','white')
We notice the clear advantage of the multi-band approach. By relaxing constraints in the transition region, we allowed the equiripple algorithm to converge to a solution with lower passband ripples and a greater stopband attenuation. In other words we could match the frequency characteristics of the first filter with a lower order.
close(gcf)
Single-Band vs Multi-Band IIR Designs
Similarly when using IIR filters, some designs problems where no transition band can be easily identified are best resolved with a single (full) band specification approach. As an example, we model the optical absorption of a gas (atomic Rubidium87 vapor):
Nb = 12; Na = 10; F = linspace(0,1,100); As = ones(1,100)-F*0.2; Absorb = [ones(1,30),(1-0.6*bohmanwin(10))',... ones(1,5), (1-0.5*bohmanwin(8))',ones(1,47)]; A = As.*Absorb; d = fdesign.arbmag('Nb,Na,F,A',Nb,Na,F,A); W = [ones(1,30) ones(1,10)*.2 ones(1,60)]; design(d, 'iirlpnorm', 'Weights', W, 'Norm', 2, 'DensityFactor', 30); set(gcf,'Color','white')
close(gcf)
In other cases where constraints can be relaxed in one a more transition bands, the multiband band approach provides the same benefits as in the FIR case (namely better passband and stopband caracteristics). We illustrate that difference by modeling a Rayleigh fading wireless communications channel:
Nb = 4; Na = 6; F = [0:0.01:0.4 .45 1]; A = [1.0./(1-(F(1:end-2)./0.42).^2).^0.25 0 0]; d = fdesign.arbmag('Nb,Na,F,A',Nb,Na,F,A); Hd = design(d,'iirlpnorm'); B = 2; F1 = F(1:end-2); % Passband F2 = F(end-1:end); % Stopband % F(end-2:end-1)=[.4 .45] % Transition band A1 = A(1:end-2); A2 = A(end-1:end); d = fdesign.arbmag('Nb,Na,B,F,A',Nb,Na,B,F1,A1,F2,A2); Hd(2) = design(d,'iirlpnorm'); hfvt = fvtool(Hd, 'Designmask','on'); legend(hfvt, 'Single-Band Design', 'Multi-Band Design'); set(gcf,'Color','white')
close(gcf)
Store