Main Content

Implement aMATLAB SystemBlock

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 theMATLAB Systemblock from the User-Defined Functions library.

  2. In the block dialog box, from theNewlist, selectBasic,Advanced, orSimulink Extensionif 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 theSystem object name. Click the list arrow. If valid System objects exist in the current folder, the names appear in the list.

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

Note

After you associate the block with a System object class name, you cannot assign a new System object using the sameMATLAB Systemblock dialog box. Instead, right-click theMATLAB Systemblock, selectBlock Parameters (MATLABSystem)and enter a new class name inSystem object name.

Understanding theMATLAB SystemBlock

  1. Double-click the block. TheMATLAB Systemblock dialog box reflects the System object parameters. The dialog box usually includes aSource codelink that leads to the System object class file. For example:

    TheSource codelink 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 thegetHeaderImplmethod

  2. ClickSource codeand observe that the public and active properties in the System object appear in theMATLAB Systemblock dialog box as block parameters.

  3. Select how you want the model to simulate the block using theSimulate usingparameter. (This parameter appears at the bottom of eachMATLAB Systemblock if there is only one tab, or the bottom of the first of multiple tabs.)

Related Examples

More About