Two examples of frequency manipulation

Masking



2) To make the subsystem configurable, you will mask it, which is the Simulink way of saying that you will give it a working interface. Close the Transfer Function subsystem, select the "Subsystem" block (we will rename it later), and use the "Edit>Create Mask" to create this interface. You will be prompted with the following Mask (or interface) parameterization dialog

Mask

The "Icon and Ports" commands the appearance of the block. We will come back to it later, as it will depend on the parameters section. We will turn our attention to the parameters tab. These are the parameters that you will pass to the mask and underlying block to make it work. There are three parameters:

  • The order N of the filter
  • The cutting frequency OmegaC of the filter
  • A boolean "plot" which tells the mask to draw (or not) the transfer of the filter during initialization
You should end with something like this

MaskParameters

Now let us turn to the strategic part of the block: the initialization tab. This where you will put the script that will be executed by the block at initialization time (before the simulation start). Here we will compute the numerator variable num and denominator variable den of the Transfer Function so it behaves like a Butterworth filter of order N with cutting frequency OmegaC. These parameters come from the Mask dialog.

This where your work start. Duplicate you block now as you will need two different scripts.
You will write two initialization scripts that initialize a low pas or high pass (depending on the block) and optionally plots the transfer function with 1000 points. It may be the time to go back and take a look at the Butterworth Filters page. These scripts will set the num and den parameters of the inside transfer function blocks.

Finally, it will be time to go back to the "Icon and Ports" tab to enter the drawing script. The script is
disp(['order=' num2str(N) '\n Frequency=' num2str(OmegaC/(2*pi))])

Rename the Masked blocks to "Butterworth Low pass" and "Butterworth High pass" once this is done.

When using the filters, do not forget that OmegaC is actually an angular velocity, so, if you aim to have a cutting frequency at 1 Hz, enter 2*pi in the frequency field of the dialog box.

The solution model (with the two blocks) is here.