Rules for Using Simulink Functions in Stateflow Charts
Do not call Simulink functions in state during actions
or transition conditions of continuous-time charts
This rule applies to continuous-time charts because you cannot
call functions during minor time steps. You can call Simulink functions
in state entry or exit actions
and transition actions. However, if you try to call Simulink functions
in state during actions or transition conditions,
an error message appears when you simulate your model.
For more information, see Modeling Continuous-Time Systems in Stateflow Charts.
Do not call Simulink functions in default transitions
if you enable execute-at-initialization mode
If you select Execute (enter) Chart At Initialization in
the Chart properties dialog box, you cannot call Simulink functions
in default transitions that execute the first time that the chart
awakens. Otherwise, an error message appears when you simulate your
model.
Use only alphanumeric characters or underscores when naming
input and output ports for a Simulink function
This rule ensures that the names of input and output ports are
compatible with identifier naming rules of Stateflow charts.
Note
Any space in a name automatically changes to an underscore. |
Convert discontiguous signals to contiguous signals for Simulink functions
For Simulink functions inside a Stateflow chart, the
output ports do not support discontiguous signals. If your function
contains a block that outputs a discontiguous signal, insert a Signal
Conversion block between the discontiguous output and the
output port. This action ensures that the output signal is contiguous.
Blocks that can output a discontiguous signal include the Bus
Creator block and the Mux block. For the Bus
Creator block, the output is discontiguous only if you clear
the Output as nonvirtual bus check box—that
is, if the Bus Creator block outputs a virtual bus.
If you select Output as nonvirtual bus, the
output signal is contiguous and no conversion is necessary.
For more information, see Bus Creator, Mux, and Signal Conversion in
the Simulink Reference documentation.
Do not export Simulink functions
If you try to export Simulink functions, an error message
appears when you simulate your model. To avoid this problem, clear
the Export Chart Level Graphical Functions (Make Global) check
box in the Chart properties dialog box.
Use the Stateflow Editor to rename a Simulink function
If you try to use the Model Explorer to rename a Simulink function,
the change does not appear in the chart. Click the function box in
the Stateflow Editor to rename the function.
Do not use Simulink functions in Moore charts
Do not generate HDL code for Simulink functions
If you try to generate HDL code for charts that contain Simulink functions,
an error message appears when you simulate your model. HDL code generation
does not support Simulink functions.
 | How a Simulink Function Behaves When Called from Multiple Sites | | Best Practices for Using Simulink Functions |  |
Learn how engineers use Stateflow to model state machines in their Simulink models.
Get free kit