| Contents | Index |
When you define a function that uses Simulink 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
For details about each modeling method, see Benefits of Using a Simulink Function to Access Simulink Blocks and Benefits of Using a Simulink Function to Schedule Execution of Multiple Controllers.
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 Function-Call Subsystems in Simulink User's Guide). 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 Defining a Function That Uses Simulink Blocks.
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.

You define each controller as a Simulink function in a Stateflow chart and use function calls to schedule execution of the subsystems, as shown.

This modeling method minimizes the objects in your model.

For more information, see Scheduling Execution of Multiple Controllers.
![]() | Differences Between Simulink Functions and Function-Call Subsystems | Where to Use a Simulink Function | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |