Compare Single-Rate/Single-Stage Filters with Multirate/Multistage Filters
This example shows the efficiency gains that are possible when using multirate and multistage filters for certain applications. In this case a distinct advantage is achieved over regular linear-phase equiripple design when a narrow transition-band width is required. A more detailed treatment of the key points made here can be found in the example entitled Efficient Narrow Transition Band FIR Filter Design
Single-Rate/Single-Stage Equiripple Design
Consider the following design specifications for a lowpass filter (where the ripples are given in linear units):
Fpass = 0.13; % Passband edge Fstop = 0.14; % Stopband edge Rpass = 0.001; % Passband ripple, 0.0174 dB peak to peak Rstop = 0.0005; % Stopband ripple, 66.0206 dB minimum attenuation Hf = fdesign.lowpass(Fpass,Fstop,Rpass,Rstop,'linear');
A regular linear-phase equiripple design using these specifications can be designed by evaluating the following:
lpFilter = design(Hf,'equiripple','SystemObject',true);
When you determine the cost of this design, you can see that 695 multipliers are required.
ans = struct with fields: NumCoefficients: 695 NumStates: 694 MultiplicationsPerInputSample: 695 AdditionsPerInputSample: 694
Reduce Computational Cost Using Mulitrate/Multistage Design
The number of multipliers required by a filter using a single state, single rate equiripple design is 694. This number can be reduced using multirate/multistage techniques. In any single-rate design, the number of multiplications required by each input sample is equal to the number of non-zero multipliers in the implementation. However, by using a multirate/multistage design, decimation and interpolation can be combined to lessen the computation required. For decimators, the average number of multiplications required per input sample is given by the number of multipliers divided by the decimation factor.
lpFilter_multi = design(Hf,'multistage','SystemObject',true);
You can then view the cost of the filter created using this design step, and you can see that a significant cost advantage has been achieved.
ans = struct with fields: NumCoefficients: 396 NumStates: 352 MultiplicationsPerInputSample: 73 AdditionsPerInputSample: 70.8333
Compare the Frequency Responses
fvt = fvtool(lpFilter,lpFilter_multi); legend(fvt,'Equiripple design', 'Multirate/multistage design')
Notice that the stopband attenuation for the multistage design is about twice that of the other designs. This is because the decimators must attenuate out-of-band components by 66 dB in order to avoid aliasing that would violate the specifications. Similarly, the interpolators must attenuate images by 66 dB. You can also see that the passband gain for this design is no longer 0 dB, because each interpolator has a nominal gain (in linear units) equal to its interpolation factor, and the total interpolation factor for the three interpolators is 6.
Compare the Power Spectral Densities
You can check the performance of the multirate/multistage design by plotting the power spectral densities of the input and the various outputs, and you can see that the sinusoid at is attenuated comparably by both the equiripple design and the multirate/multistage design.
n = 0:1799; x = sin(0.1*pi*n') + 2*sin(0.15*pi*n'); y = lpFilter(x); y_multi = lpFilter_multi(x); [Pxx,w] = periodogram(x); Pyy = periodogram(y); Pyy_multi = periodogram(y_multi); plot(w/pi,10*log10([Pxx,Pyy,Pyy_multi])); xlabel('Normalized Frequency (x\pi rad/sample)'); ylabel('Power density (dB/rad/sample)'); legend('Input signal PSD','Equiripple output PSD',... 'Multirate/multistage output PSD') axis([0 1 -50 30]) grid on