主要内容

Simulink Function

R2026b

Simulink function subsystem in Stateflow chart

Description

A Simulink® function embeds a Simulink subsystem inside a Stateflow® chart. You can use the Simulink function to call Simulink blocks in the actions of states and transitions, or to define functions that require Simulink blocks.

To add a Simulink function to a chart:

  1. In the Stateflow Editor, in the object palette, click the Simulink Function icon The Simulink function object palette icon..

  2. Click a location in the chart canvas to place the Simulink function.

  3. Type a function signature in the format y = f(x).

Properties

expand all

To edit graphical object properties interactively, right-click the object and select Properties.

To modify Simulink function properties programmatically, use Stateflow.SLFunction objects.

Main

Display of port labels on the Simulink function, specified as one of these values:

  • FromPortIcon — Show port labels derived from the port icon.

  • FromBlockName — Show port labels derived from the block name.

  • none — Hide port labels.

Name of the MATLAB® function to call when an error occurs in the subsystem, specified as a character vector.

Scope of workspace variable resolution for the subsystem, specified as one of these values:

  • All — Resolve all variables by searching the model hierarchy.

  • ExplicitOnly — Resolve only variables that are explicitly defined in the subsystem.

  • None — Do not resolve variables through the model hierarchy.

Option to display reinitialize ports on the Simulink function. Select this check box to show reinitialize ports that reset the subsystem state during simulation.

Code Generation

Packaging of generated code for the Simulink function subsystem, specified as one of these values:

  • Auto — An internal calculation determines the packaging of the function in generated code.

  • Nonreusable function — Generate the function as a nonreusable function.

  • Reusable function — Generate the function as a reusable function with a separate data structure for its data.

  • Inline — Inline the function code at each call site.

Subsystem Reference

Convert the Simulink function to a referenced subsystem with its content saved in a separate file. Click Convert to open the conversion dialog box.

Version History

Introduced in R2008b