Main Content

Implement a MATLAB System Block

Implement a block and assign a System object™ to it. You can then explore the block to see the effect.

  1. Create a new model and add the MATLAB System block from the User-Defined Functions library.

  2. In the block dialog box, from the New list, select Basic, Advanced, or Simulink Extension if you want to create a new System object from a template. Modify the template according to your needs and save the System object.

  3. Enter the full path name for the System object in the System object name. Click the list arrow. If valid System objects exist in the current folder, the names appear in the list.

    The MATLAB System block icon and port labels update to those of the corresponding System object. For example, suppose you selected a System object named lmsSysObj in your current folder. The block updates as shown in the figure:


After you associate the block with a System object class name, you cannot assign a new System object using the same MATLAB System block dialog box. Instead, right-click the MATLAB System block, select Block Parameters (MATLABSystem) and enter a new class name in System object name.

Understanding the MATLAB System Block

  1. Double-click the block. The MATLAB System block dialog box reflects the System object parameters. The dialog box usually includes a Source code link that leads to the System object class file. For example:

    The Source code link appears if the System object uses MATLAB® language. It does not appear if you have:

    • Converted the System object to P-code

    • Overridden the default behavior using the getHeaderImpl method

  2. Click Source code and observe that the public and active properties in the System object appear in the MATLAB System block dialog box as block parameters.

  3. Select how you want the model to simulate the block using the Simulate using parameter. (This parameter appears at the bottom of each MATLAB System block if there is only one tab, or the bottom of the first of multiple tabs.)

Related Examples

More About