Main Content


Visualize filter stages



visualizeFilterStages(sysobj) shows the response of each individual filter stage of the filter System object™ using FVTool.


collapse all

Filter an input signal through a complex bandpass decimator and visualize the filtered spectrum in a spectrum analyzer.


Create a dsp.ComplexBandpassDecimator System object™ with center frequency set to 2000 Hz, bandwidth of interest set to 1000 Hz, and sample rate set to 48 kHz. The decimation factor is computed as the ratio of the sample rate to the bandwidth of interest. The input to the decimator is a sine wave with a frame length of 1200 samples with tones at 1625 Hz, 2000 Hz, and 2125 Hz. Create a dsp.SpectrumAnalyzer scope to visualize the signal spectrum.

Fs = 48e3;
CF = 2000;
BW = 1000;
D  =  Fs/BW;
FrameLength = 1200;
bpdecim = dsp.ComplexBandpassDecimator(D,CF,Fs);

sa = dsp.SpectrumAnalyzer('SampleRate',Fs/D,...
    'YLimits',[-120 40],...

tones = [1625 2000 2125];
sin = dsp.SineWave('SampleRate',Fs,'Frequency',tones,...

Visualize Filter Stages

Using the visualizeFilterStages function, you can visualize the response of each individual filter stage using FVTool.


Display Filter info

The info function displays information about the bandpass decimator.

Overall Decimation Factor       : 48
Bandwidth                       : 1000 Hz
Number of Filters               : 5
Real multiplications per Input Sample: 14.708333
Real additions per Input Sample      : 13.833333
Number of Coefficients               : 89
   Filter 1:
   dsp.FIRDecimator     - Decimation Factor   : 2 
   Filter 2:
   dsp.FIRDecimator     - Decimation Factor   : 2 
   Filter 3:
   dsp.FIRDecimator     - Decimation Factor   : 2 
   Filter 4:
   dsp.FIRDecimator     - Decimation Factor   : 3 
   Filter 5:
   dsp.FIRDecimator     - Decimation Factor   : 2 

Stream In and Filter Signal

Construct a for-loop to run for 1000 iterations. In each iteration, stream in 1200 samples (one frame) of the noisy sine wave and apply the complex bandpass decimator on each frame of the input signal. Visualize the input and output spectrum in the spectrum analyzer, sa.

for index = 1:1000
    x = sum(sin(),2) +  1e-4*randn(FrameLength,1);
    z = bpdecim(x);

The bandpass decimator with center frequency at 2000 Hz and a bandwidth of 1000 Hz passes the three sine wave tones at 1625 Hz, 2000 Hz, and 2125 Hz.

Change the center frequency of the decimator to 2400 Hz and filter the signal.

bpdecim.CenterFrequency = 2400
bpdecim = 

  dsp.ComplexBandpassDecimator with properties:

                CenterFrequency: 2400
                  Specification: 'Decimation factor'
               DecimationFactor: 48
            StopbandAttenuation: 80
                TransitionWidth: 100
    MinimizeComplexCoefficients: true
                     SampleRate: 48000

Configure the spectrum analyzer to show the bandwidth of interest, [-1900, 2900] Hz.

sa.FrequencyOffset = 2400;

Stream in the data and filter the signal.

for index = 1:1000
    x = sum(sin(),2) +  1e-4 * randn(FrameLength,1);
    z = bpdecim(x);

The tones at 2000 Hz and 2125 Hz are passed through the decimator, while the tone at 1625 Hz is filtered out.

Create a multistage sample rate converter with default properties, corresponding to the combined three filter stages used to convert from 192 kHz to 44.1 kHz. Visualize the stages.

src = dsp.SampleRateConverter;

Figure Filter Visualization Tool - Magnitude Response (dB) contains an axes and other objects of type uitoolbar, uimenu. The axes with title Magnitude Response (dB) contains 3 objects of type line. These objects represent Filter #1, Filter #2, Filter #3.

Input Arguments

collapse all

Filter System object, specified as one of the following:

Introduced in R2012a