Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Solutions Academia Support User Community Company
spacer spacer spacer spacer spacer spacer

 

Filter Design Toolbox 4.6

Design of Decimators/Interpolators

Typically lowpass filters are used for decimation and for interpolation. When decimating, lowpass filters are used to reduce the bandwidth of a signal prior to reducing the sampling rate. This is done to minimize aliasing due to the reduction in the sampling rate. When interpolating, lowpass filters are used to remove spectral images from the low-rate signal. For general notes on lowpass filter design see Designing Lowpass FIR Filters With the Filter Design Toolbox™

Contents

Design of Decimators

When decimating, the bandwidth of a signal is reduced to an appropriate value so that minimal aliasing occurs when reducing the sampling rate. Suppose a signal that occupies the full Nyquist interval (i.e. has been critically sampled) has a sampling rate of 200 Hz. The signal's energy extends up to 100 Hz. If we'd like to reduce the sampling rate by a factor of 4 to 50 Hz, significant aliasing will occur unless the bandwidth of the signal is also reduced by a factor of 4. Ideally, a perfect lowpass filter with a cutoff at 25 Hz would be used. In practice, several things will occur: The signal's components between 0 and 25 Hz will be slightly distorted by the passband ripple of a non-ideal lowpass filter; there will be some aliasing due to the finite stopband attenuation of the filter; the filter will have a transition band which will distort the signal in such band. The amount of distortion introduced by each of these effects can be controlled by designing an appropriate filter. In general, to obtain a better filter, a higher filter order will be required.

Let's start by designing a simple lowpass decimator with a decimation factor of 4.

M   = 4;   % Decimation factor
Fp  = 23;  % Passband-edge frequency
Fst = 25;  % Stopband-edge frequency
Ap  = 0.1; % Passband peak-to-peak ripple
Ast = 80;  % Minimum stopband attenuation
Fs  = 200; % Sampling frequency
Hf = fdesign.decimator(M,'lowpass',Fp,Fst,Ap,Ast,Fs)
Hf =

          MultirateType: 'Decimator'
               Response: 'Lowpass'
       DecimationFactor: 4
          Specification: 'Fp,Fst,Ap,Ast'
            Description: {4x1 cell}
    NormalizedFrequency: false
                     Fs: 200
                  Fs_in: 200
                 Fs_out: 50
                  Fpass: 23
                  Fstop: 25
                  Apass: 0.1
                  Astop: 80

The specifications for the filter determine that a transition band of 2 Hz is acceptable between 23 and 25 Hz and that the minimum attenuation for out of band components is 80 dB. Also that the maximum distortion for the components of interest is 0.05 dB (half the peak-to-peak passband ripple). An equiripple filter that meets these specs can be easily obtained as follows:

Hm = design(Hf,'equiripple');
hfvt = fvtool(Hm,'DesignMask','on','Color','White');
measure(Hm)
ans =

Sampling Frequency : 200 Hz
Passband Edge      : 23 Hz
3-dB Point         : 23.5594 Hz
6-dB Point         : 23.7824 Hz
Stopband Edge      : 25 Hz
Passband Ripple    : 0.09498 dB
Stopband Atten.    : 80.0526 dB
Transition Width   : 2 Hz

It is clear from the measurements that the design meets the specs.

Multistage Design

It may be preferable to use a multistage approach to obtain a more efficient design that meets the specs. For more on this, see Multistage Design Of Decimators/Interpolators. Here we show an IFIR design.

Hm(2) = design(Hf,'ifir');
set(hfvt,'Filters',[Hm(1) Hm(2)]);
legend(hfvt,'Single-stage equiripple design','Two-stage IFIR design')

Using Nyquist Filters

Nyquist filters are attractive for decimation and interpolation due to the fact that a 1/M fraction of the number of coefficients is zero. The band of the Nyquist filter is typically set to be equal to the decimation factor, this centers the cutoff frequency at 1/M*Fs/2. In this example, the transition band is centered around 1/4*100 = 25 Hz.

TW = 2; % Transition width of 2 Hz
Hfn = fdesign.decimator(M,'nyquist',M,TW,Ast,Fs)
Hfn =

          MultirateType: 'Decimator'
               Response: 'Nyquist'
       DecimationFactor: 4
          Specification: 'TW,Ast'
            Description: {'Transition Width';'Stopband Attenuation (dB)
'}
                   Band: 4
    NormalizedFrequency: false
                     Fs: 200
                  Fs_in: 200
                 Fs_out: 50
        TransitionWidth: 2
                  Astop: 80

A Kaiser window design can be obtained in a straightforward manner.

Hmn = design(Hfn,'kaiserwin');
set(hfvt,'Filters',[Hm(1) Hmn]);
legend(hfvt,'Equiripple lowpass filter','Kaiser window Nyquist filter')

A more efficient design can be obtained through multistage techniques which results in two halfband filters cascaded

Hmn(2) = design(Hfn,'multistage');
set(hfvt,'Filters',Hmn);
legend(hfvt,'Kaiser window Nyquist filter','Multistage Nyquist filter')

Aliasing with Nyquist Filters

Suppose the signal to be filtered has a flat spectrum. Once filtered, it acquires the spectral shape of the filter. After reducing the sampling rate, this spectrum is repeated with replicas centered around multiples of the new lower sampling frequency. An illustration of the spectrum of the decimated signal can be found from:

NFFT = 4096;
[H,f] = freqz(Hmn(1),NFFT,'whole',Fs);
plot(f-100,20*log10(abs(fftshift(H))))
grid on
hold on
plot(f-50,20*log10(abs(fftshift(H))),'r-')
plot(f-150,20*log10(abs(fftshift(H))),'k-')
legend('Baseband spectrum','First positive replica','First Negative replica'
)
set(gcf,'Color','White');
hold off

Note that the replicas overlap somewhat, so aliasing is introduced. However, the aliasing only occurs in the transition band. That is, significant energy (above the prescribed 80 dB) from the first replica only aliases into the baseband between 24 and 25 Hz. Since the filter was transitioning in this region anyway, the signal has been distorted in that band and aliasing there is not important.

On the other hand, notice that although we have used the same transition width as with the lowpass design from above, we actually retain a wider usable band (24 Hz rather than 23) when comparing this Nyquist design with the original lowpass design. To illustrate this, let's follow the same procedure to plot the spectrum of the decimated signal when the lowpass design from above is used

[H,f] = freqz(Hm(1),NFFT,'whole',Fs);
plot(f-100,20*log10(abs(fftshift(H))))
grid on
hold on
plot(f-50,20*log10(abs(fftshift(H))),'r-')
plot(f-150,20*log10(abs(fftshift(H))),'k-')
legend('Baseband spectrum','First positive replica','First Negative replica'
)
set(gcf,'Color','White');
hold off

In this case, there is no significant overlap (above 80 dB) between replicas, however because the transition region started at 23 Hz, the resulting decimated signal has a smaller usable bandwidth.

Decimating by 2. Halfband Filters

When the decimation factor is 2, the Nyquist filter becomes a halfband filter. These filters are very attractive because just about half of their coefficients are equal to zero. Often, to design Nyquist filters when the band is an even number, it is desirable to perform a multistage design that uses halfband filters in some/all of the stages.

Hf = fdesign.decimator(2,'halfband');
Hd = design(Hf,'equiripple')
set(hfvt,'Filters',Hd,'legend','off');
Hd =

     FilterStructure: 'Direct-Form FIR Polyphase Decimator'
          Arithmetic: 'double'
           Numerator: [1x95 double]
    DecimationFactor: 2
    PersistentMemory: false

As with other Nyquist filters, when halfbands are used for decimation, aliasing will occur only in the transition region.

Interpolation

When interpolating a signal, the baseband response of the signal should be left as unaltered as possible. Interpolation is obtained by removing spectral replicas when the sampling rate is increased.

Suppose we have a signal sampled at 48 Hz. If it is critically sampled, there is significant energy in the signal up to 24 Hz. If we want to interpolate by a factor of 4, we would ideally design a lowpass filter running at 192 Hz with a cutoff at 24 Hz. As with decimation, in practice an acceptable transition width needs to be incorporated into the design of the lowpass filter used for interpolation along with passband ripple and a finite stopband attenuation. For example, consider the following specs:

L   = 4;   % Interpolation factor
Fp  = 22;  % Passband-edge frequency
Fst = 24;  % Stopband-edge frequency
Ap  = 0.1; % Passband peak-to-peak ripple
Ast = 80;  % Minimum stopband attenuation
Fs  = 192; % Sampling frequency
Hf = fdesign.interpolator(L,'lowpass',Fp,Fst,Ap,Ast,Fs)
Hf =

          MultirateType: 'Interpolator'
               Response: 'Lowpass'
    InterpolationFactor: 4
          Specification: 'Fp,Fst,Ap,Ast'
            Description: {4x1 cell}
    NormalizedFrequency: false
                     Fs: 192
                  Fs_in: 48
                 Fs_out: 192
                  Fpass: 22
                  Fstop: 24
                  Apass: 0.1
                  Astop: 80

An equiripple design that meets the specs can be found in the same manner as with decimators

Hm = design(Hf,'equiripple');
set(hfvt,'Filters',Hm,'legend','off');

Notice that the filter has a gain of 12 dB which corresponds to a gain of 4 in linear units. In general interpolators will have a gain equal to the interpolation factor. This is needed for the signal being interpolated to maintain the same range after interpolation. For example,

n = 0:300;
f = 18; % Frequency of the sinusoid
x = sin(2*pi*f*n'/Fs);
y = filter(Hm,x);
stem(y(163:300)) % Plot the output after transition period has ended
xlabel('Discrete time')
ylabel('Amplitude')
set(gcf,'Color','White');

Note that although the filter has a gain of 4, the interpolated signal has the same amplitude as the original signal.

Use of Nyquist Filters for Interpolation

Similar to the decimation case, Nyquist filters are attractive for interpolation purposes. Moreover, given that there is a coefficient equal to zero every L samples, the use of Nyquist filters ensures that the samples from the input signal are retained unaltered at the output. This is not the case for other lowpass filters when used for interpolation (on the other hand, distortion may be minimal in other filters, so this is not necessarily a huge deal).

TW = 2;
Hfn = fdesign.interpolator(L,'nyquist',L,TW,Ast,Fs)
Hd = design(Hfn,'kaiserwin');
set(hfvt,'Filters',Hd,'legend','off');
Hfn =

          MultirateType: 'Interpolator'
               Response: 'Nyquist'
    InterpolationFactor: 4
          Specification: 'TW,Ast'
            Description: {'Transition Width';'Stopband Attenuation (dB)
'}
                   Band: 4
    NormalizedFrequency: false
                     Fs: 192
                  Fs_in: 48
                 Fs_out: 192
        TransitionWidth: 2
                  Astop: 80

In an analogous manner to decimation, when used for interpolation, Nyquist filters allow some degree of imaging. That is, some frequencies above the cutoff frequency are not attenuated by the value of Ast. However, this occurs only in the transition band of the filter. On the other hand, once again a wider portion of the baseband of the original signal is maintained intact when compared to a lowpass filter with stopband-edge at the ideal cutoff frequency when both filters have the same transition width.

Contact sales
Free technical kit
Trial software
E-mail this page

Get Pricing and
Licensing Options