Python Custom Block
Define this block with Python commands and functions.
-
From the Palette Browser, select . Drag the block into your diagram and double-click it.
The block dialog appears with tabs to define the Ports, States, Parameters, SimFunction and other advanced properties for the block.
- On the Ports tab, enter the number of input and output ports for the block, enter a name for each port, then click OK.
- On the States tab, enter the state of the block with respect to its initial continuous condition, initial state derivative, initial discrete state, and number of initial object states, then click OK.
- On the Parameters tab, enter the number of parameters for the block. For each parameter, enter a name, value, and type, then click OK.
- On the SimFunction tab, generate a code skeleton, enter the simulation function for your block, then click OK. The skeleton provides the essential framework for the Python function that handles the interface with inputs, outputs and events.
- On the Advanced tab, enter the number of modes and zero-crossings for the block, select the activation mode: always active, initially active or standard, then click OK.