Main Content

State

R2026b

Operating mode in Stateflow chart

Description

A state represents an operating mode of a reactive system in a Stateflow® chart. States define the conditions under which a system operates and the actions the system takes while in those conditions.

To add a state to a chart:

  1. In the Stateflow Editor, in the object palette, click the State icon The state object palette icon..

  2. Click a location in the chart canvas to place the state.

  3. Type a name for the state.

Properties

expand all

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

To modify state properties programmatically, use Stateflow.State objects.

General

Name of the state in the chart hierarchy. This property is read-only. Click the hyperlink to navigate to the state in the Stateflow Editor. To change the name, edit the label on the chart canvas.

Option to create an output port that outputs the active state data for the state. When you select this check box, use the drop-down list to choose the type of output port to create:

  • Self activity — Output whether the state itself is active.

  • Child activity — Output which child state is active.

  • Leaf state activity — Output which leaf-level child state is active.

Appearance of the state functions in generated code, specified as one of these values:

  • Auto — An internal calculation determines the appearance of state functions in generated code.

  • Function — Implement state functions as separate static functions.

  • Inline — If the function is not part of a recursion, calls to state functions are replaced by code.

Label for the state, specified as a character vector. The label defines the state name and its entry, during, exit, and on actions as they appear in the Stateflow Editor.

Logging

Option to log the self activity of the state during simulation. Select this check box to save the active state data to the MATLAB® workspace.

Option to set the state as a test point. Select this check box to enable monitoring the state activity during simulation. For example, enable this property to monitor the state with a Floating Scope block or log its values to the MATLAB workspace.

Source of the signal name for logging, specified as one of these values:

  • Use state name — Use the state name as the logging signal name.

  • Custom — Use a custom name as the logging signal name. Enter the custom name in the text field.

Option to limit the number of data points logged during simulation. To specify the maximum number of data points, select this check box and enter a value in the text field. The default limit is 5000 data points.

Option to log every Nth data point during simulation. Select this check box and specify the decimation interval in the adjacent field. The default decimation interval is 2.

Documentation

Description of the state, specified as a character vector.

Link to a document associated with the state, specified as a character vector. Enter a web URL or a MATLAB expression that opens the document.

Version History

Introduced before R2006a