C Custom Block
Define this block with C commands and functions.
-
From the Palette Browser, select . Drag and drop 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 C function that interfaces with inputs, outputs and events.
Additional options:
- Check the syntax of the C function with the check C code button.
- Export a DLL with the generate dll and convert button.
- 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.