When you define a function that uses Simulink® function-call subsystem blocks or schedule execution of multiple controllers without Simulink functions, the model requires these elements:
Simulink function-call subsystem blocks
Stateflow® chart with function-call output events
Signal lines between the chart and each function-call subsystem port
Simulink functions in a Stateflow chart provide these advantages:
No function-call subsystem blocks
No output events
No signal lines
The sections that follow compare two ways of defining a function that uses Simulink blocks.
You define a function-call subsystem in the Simulink model (see Using Function-Call Subsystems. Use an output event in a Stateflow chart to call the subsystem, as shown.
You place one or more Simulink blocks in a Simulink function of a Stateflow chart. Use a function call to execute the blocks in that function, as shown.
In the chart, the during
action in
selection_state
contains a function call to
calc_th
, which is a function that contains Simulink blocks.
This modeling method minimizes the objects in your model.
For more information, see Improve Chart Design by Using Simulink Functions.
The sections that follow compare two ways of scheduling execution of multiple controllers.
You define each controller as a function-call subsystem block and use output events in
a Stateflow chart to schedule execution of the subsystems, as shown in the
sf_temporal_logic_scheduler
model.
You define each controller as a Simulink function in a Stateflow chart and use function calls to schedule execution of the subsystems, as
shown in the sf_temporal_logic_scheduler_with_sl_fcns
model.
This modeling method minimizes the objects in your model.