Main Content

Model RF Filter Using Circuit Envelope

This example shows how to model an RF filter using Circuit Envelope Library. In this example you compare the input and output signal amplitudes to study the signal attenuation.

Model Overview

This example uses an LC bandpass filter designed to have a bandwidth of 200 MHz. The filter uses a three tone input signal to demonstrate the filter attenuation property for in-band and out-band frequencies. The input signal tones are:

  • 700 MHz — Center frequency of the filter passband

  • 600 MHz — Lower edge frequency of the filter passband

  • 900 MHz — Frequency outside the filter passband

Define Model Variables and Settings

Define model variables for blocks that share parameter values using the InitFcn:

  1. In Simulink® editor, click Modeling. In the toolstrip, in SETUP> Model Settings, click Model Properties.

  2. In the Model Properties dialog box, on the Callbacks tab in Model callbacks pane, select InitFcn.

  3. In the Model initialization function pane, enter:

    amp = ones(1,3)
    freq = [600 700 900]*1e6
    stepsize = 1/500e6
  4. Click OK.

  5. In the Simulink tool bar, change the Simulation stop time to 0.

  6. In Simulink editor, click Simulation In the PREPARE, click Model Settings in Configuration and Simulation In the Solver tab, in Solver options change the Solver to discrete (no continuous states).

Required Blocks

The filter system consists of LC Ladder, Inport, Outport and Configuration blocks. The physical part of the model uses bidirectional RF signals.

The blocks used in the system are:


Library Path



ConstantSimulink > Sources

To generate real and complex constant value


InportRF Blockset > Circuit Envelope > Utilities

To convert Simulink input signal to RF Blockset™ input signal


ConfigurationRF Blockset > Circuit Envelope > Utilities

To set the system wide parameters for RF Blockset simulation


LC LadderRF Blockset > Circuit Envelope > Elements

To models the signal attenuation


OutportRF Blockset > Circuit Envelope > Utilities

To convert RF Blockset signals to Simulink signals


db ConversionDSP System Toolbox > Math Functions > Math Operations

To convert magnitude data to decibels


Math FunctionSimulink > Math Operations

To perform mathematical functions


To workspaceSimulink > Sinks

To write data to a MATLAB® workspace for plotting


TerminatorSimulink > Commonly Used Blocks > Terminator

To terminate the angle baseband output of the Outport block


Connect the blocks as shown in the figure:

Circuit envelope RF filter model

Configure Input Signal

Generate the three-tone input signal using these blocks:

  • Constant block specifies the amplitude of the signal.

  • Inport block configures the frequencies of the three tones.

  • Configuration block specifies the step size.

  1. In the Constant block dialog box set the Constant value to amp, as defined in the InitFcn.

  2. In the Inport block:

    • Set Source type to Power.

    • Set Carrier frequencies to freq, as defined in InitFcn. The freq variable sets the frequency of the three tones to 600 MHz, 700 MHz, and 900 MHz respectively.

      Click OK.

  3. In the Configuration block dialog box:

    • Set Step size to step size, as defined in InitFcn.

    • Clear Simulate noise.

      Click OK.

    The fundamental tones and harmonics are updated automatically when you run the model.

Configure RF Filter

  1. In the LC Ladder block dialogue box:

    • Set Ladder topology to LC Bandpass Pi.

      Click Apply and then click OK.

Configure Output Settings

  1. In the Outport block :

    • Set Sensor type to Power.

    • Set Output to Magnitude and Angle Baseband.

    • Set Carrier frequencies to freq, as defined in InitFcn.

      Click OK.

  2. In the Simulink editor, connect the Ang port of the Outport block to Terminator block to terminate the angle baseband output.

  3. In Math Function and Math Function 1 block dialog boxes, set Function to magnitude^2 and click OK. The block squares the magnitude of the input and output signal.

  4. In dB Conversion and dB Conversion 1 block dialog boxes, set Input Signal to Power and click OK. The block converts the input and output signals to dB.

  5. In To Workspace, change the Variable name to In. In To Workspace 1, change the Variable name to Out. In both the block dialog boxes, change the set Save format to Array and click OK.

  6. Use Simulation > Run to run the model.

Plot and Analyze Attenuated Output Signals

Display the input and output signals using semilogx function, in dB.

  1. Transfer the input and output dB values to the MATLAB workspace using To Workspace block.

  2. To view the input signal, plot In array from the MATLAB workspace :

    h = semilogx(freq, In,'-gs','LineWidth',1,...
    title('Input Signal')
  3. To view the output signal, plot Out array from the MATLAB workspace :

    h = semilogx(freq, Out,'-gs','LineWidth',1,...
    title('Attenuated Output Signal')
  4. Compare the input and output signal plots to verify the attenuation caused by the filter.

    Input Signal to RF Filter

    Input signal to an RF Filter in Amplitude (dB) vs Frequency (Hz) plot

  5. The following plot shows the filtered attenuated signal.

    Attenuated Output Signal

    Attenuated output signal of RF Filter in Amplitude (dB) vs Frequency (Hz) plot

    Notice that the RF filter does not attenuate the signal at the center frequency of 700 MHz.

Analyze LC Bandpass Filter Response

  1. Plot more points to better understand the response of the LC bandpass filter. Change the defined variables in Model Properties to :

    amp = ones(1,201)
    freq = logspace (8,10,201)
    stepsize = 1/500e6

  2. Run the model. Notice that the signal is not attenuated within the 200 MHz range of the LC bandpass filter.

  3. Plot the attenuated output:

    h = semilogx(freq, Out,'-gs','LineWidth',1...
    title('LC Bandpass Filter Frequency Response')

    LC bandpass filter frequency response

See Also

Related Topics