Contenido principal

Atomic Box

R2026b

Encapsulate functions in separate namespace

Description

An atomic box encapsulates graphical, truth table, MATLAB®, and Simulink® functions in a separate namespace inside a Stateflow® chart. Use an atomic box to reuse functions across multiple charts and models and to isolate generated code for a specific function. Because atomic boxes are independent subcomponents, they also speed up simulation after small changes in charts with many states or levels of hierarchy.

To add an atomic box to a chart:

  1. In the Stateflow Editor, in the object palette, click the Box icon The box icon..

  2. Click a location in the chart canvas to place the atomic box.

  3. Type a name for the box.

  4. Click the box. In the toolstrip, in the Box tab, click Atomic Subchart.

Properties

expand all

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

To modify atomic box properties programmatically, use Stateflow.AtomicBox objects.

General

Name of the atomic box in the chart hierarchy, specified as a string scalar or character vector. To change the name, edit the label on the chart canvas.

Packaging of generated code for the functions inside the atomic box, specified as one of these values:

  • Auto — Stateflow determines the packaging based on the atomic box contents.

  • Nonreusable function — Generates the atomic box as a nonreusable function.

  • Reusable function — Generates the atomic box as a reusable function with a separate data structure for its data.

Subchart Properties

Action language for the atomic box, specified as one of these values:

  • MATLAB — Use MATLAB syntax in state and transition actions.

  • C — Use C syntax in state and transition actions.

Option to make chart-level functions accessible to other blocks in the model. Select this check box to export graphical functions defined at the chart level so that other Stateflow charts and Simulink blocks in the same model reference them.

Option to saturate integer data on overflow. When you select this check box, integer data in the atomic box saturates at the maximum or minimum value of the data type on overflow instead of wrapping around.

Option to treat dimensions of length 1 as fixed size rather than variable size. When you select this check box, the atomic box treats any dimension of length 1 as fixed size, regardless of the variable-size setting of the data.

Time at which variant conditions are evaluated, specified as one of these values:

  • update diagram analyze all choices — Evaluate all variant choices when you update the diagram.

  • update diagram — Evaluate variant conditions when you update the diagram and activate the valid variant choices.

  • code compile — Evaluate variant conditions at code compilation time.

  • startup — Evaluate variant conditions at model startup.

Option to create an output port for monitoring the active child state of the atomic box, specified as one of these values:

  • Child activity — Create an output port that indicates which child state is active.

  • Leaf state activity — Create an output port that indicates which leaf-level child state is active.

Fixed-Point Properties

Signal types to treat as fixed-point objects when inherited from Simulink, specified as one of these values:

  • Fixed-point — Treat only inherited fixed-point signals as fi objects.

  • Fixed-point and integer — Treat inherited fixed-point and integer signals as fi objects.

MATLAB Chart fimath

Fixed-point math settings for the atomic box, specified as one of these options:

  • Same as MATLAB — Use the default MATLAB fimath settings for fixed-point operations in the atomic box.

  • Specify other — Enter a custom fimath expression in the text field.

Version History

Introduced in R2012b