Main Content

Stateflow.Chart

Graphical representation of a finite state machine

    Description

    Use a Stateflow.Chart object to create a graphical representation of a finite state machine by combining states, transitions, and data. For more information, see Finite State Machine Concepts and Create Charts by Using the Stateflow API.

    Creation

    To create a Stateflow.Chart object, call the function sfnew. For example, to create an empty chart in a new Simulink® model called myModel, enter:

    sfnew myModel

    Alternatively, you can add a new chart to an existing model by using the function add_block (Simulink):

    add_block('sflib/Chart','myModel/Chart')

    Then, to access the Stateflow.Chart object, call the find function for the Simulink.Root object:

    rt = sfroot;
    chart = find(rt,'-isa','Stateflow.Chart', ...
        'Path','myModel/Chart');

    Properties

    expand all

    Content

    Name of the chart, specified as a character vector.

    Action language used to program the chart, specified as 'MATLAB' or 'C'. For more information, see Differences Between MATLAB and C as Action Language Syntax.

    State machine semantics implemented by the chart, specified as 'Classic', 'Mealy', or 'Moore'. For more information, see Overview of Mealy and Moore Machines.

    Whether the chart supports variable-size data, specified as a numeric or logical 1 (true) or 0 (false). Only variable-size data can change dimension during simulation. For more information, see Declare Variable-Size Data in Stateflow Charts.

    State Decomposition

    Decomposition of substates at the top level of containment in the chart, specified as 'EXCLUSIVE_OR' or 'PARALLEL_AND'. For more information, see Specify Substate Decomposition.

    Chart Initialization

    Whether to initialize the state configuration of the chart at time zero instead of at the first input event, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Execution of a Chart at Initialization.

    Behavior of the states when a function-call input event reenables the chart, specified as one of these values:

    • '' — The chart does not contain function-call input events.

    • 'held' — The chart maintains the most recent values of the states.

    • 'reset' — The chart reverts to the initial conditions of the states.

    For more information, see Control States in Charts Enabled by Function-Call Input Events.

    Whether to initialize the output data every time the chart wakes up, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Initialize outputs every time chart wakes up.

    Active State Output

    Whether to create an active state data output port for the chart, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Monitor State Activity Through Active State Data.

    This property is read-only.

    Active state data object for the chart, specified as a Stateflow.Data object. This property applies only when the HasOutputData property for the chart is true.

    Name of the active state data object for the chart, specified as a character vector. This property applies only when the HasOutputData property for the chart is true.

    Monitoring mode for the active state output data, specified as 'ChildActivity' or 'LeafStateActivity'.

    Name of the enumerated data type for the active state data object for the chart, specified as a character vector. For more information, see Enum Name.

    Whether to define the enumerated data type for the active state data output manually, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Define State Activity Enumeration Type.

    Discrete and Continuous-Time Semantics

    Activation method for the chart, specified as 'CONTINUOUS', 'DISCRETE', or 'INHERITED'. For more information, see Update Method.

    Sample time for activating the chart, specified as a character vector. This property applies only when the ChartUpdate property for the chart is 'DISCRETE'.

    Whether to enable zero-crossing detection on state transitions in the chart, specified as a numeric or logical 1 (true) or 0 (false). This property applies only when the ChartUpdate property for the chart is set to 'CONTINUOUS'. For more information, see Disable Zero-Crossing Detection.

    Super Step Semantics

    Whether to enable super step semantics for the chart, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Super Step Semantics.

    Maximum number of transitions the chart can take in one super step, specified as an integer scalar. This property applies only when the EnableNonTerminalStates property for the chart is true.

    Behavior if a super step for the chart exceeds the maximum number of transitions specified in the NonTerminalMaxCounts property before reaching a stable state, specified as one of these values:

    • 'Proceed' — The chart goes to sleep with the last active state configuration.

    • 'Throw Error' — The chart generates an error.

    This property applies only when the EnableNonTerminalStates property for the chart is true.

    Exported Functions

    Whether to export chart-level functions to other blocks in the Simulink model, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Export Stateflow Functions for Reuse.

    Whether exported functions from the chart are globally visible in the Simulink model, specified as a numeric or logical 1 (true) or 0 (false). When this property is enabled, blocks throughout the model can call functions exported from the chart without using qualified notation. This property applies only when the ExportChartFunctions property for the chart is true.

    Integer and Fixed-Point Data

    Whether the data in the chart saturates on integer overflow, specified as a numeric or logical 1 (true) or 0 (false). When this property is disabled, the data in the chart wraps on integer overflow. For more information, see Handle Integer Overflow for Chart Data.

    Inherited Simulink signals to treat as Fixed-Point Designer™ fi objects, specified as one of these values:

    • 'Fixed-point' — The chart treats all fixed-point inputs as fi objects.

    • 'Fixed-point & Integer' — The chart treats all fixed-point and integer inputs as fi objects.

    This property applies only to charts that use MATLAB® as the action language.

    Default fimath properties for the chart, specified as one of these values:

    • 'Same as MATLAB Default' — Use the same fimath properties as the current default fimath object.

    • 'Other:UserSpecified' — Use the InputFimath property to specify the default fimath object.

    This property applies only when the ActionLanguage property of the chart is 'MATLAB'.

    Default fimath object, specified as a character vector. When the EmlDefaultFimath property for the chart is 'Other:UserSpecified', you can use this property to:

    • Enter an expression that constructs a fimath object.

    • Enter the variable name for a fimath object in the MATLAB or model workspace.

    This property applies only to charts that use MATLAB as the action language.

    Code Generation

    Whether the generated code includes a preprocessor conditional statement for the variant conditions in the chart, specified as a numeric or logical 1 (true) or 0 (false). This property applies only when generating code with Embedded Coder®. For more information, see Code Generation Using Variant Transitions.

    C Action Language

    Whether to use strong data typing when the chart interfaces with Simulink input and output signals, specified as a numeric or logical 1 (true) or 0 (false). This property applies only to charts that use C as the action language. For more information, see Use strong data typing with Simulink I/O.

    Whether to use bit operations in state and transition actions in the chart, specified as a numeric or logical 1 (true) or 0 (false). This property applies only to charts that use C as the action language. For more information, see Enable C-bit operations.

    Whether to use explicit ordering of parallel states and transitions, specified as a numeric or logical 1 (true) or 0 (false). This property applies only to charts that use C as the action language. For more information, see User-specified state/transition execution order.

    Debugging

    Whether to set the On Chart Entry breakpoint for the chart, specified as a numeric or logical 1 (true) or 0 (false).

    Example: chart.Debug.Breakpoints.OnEntry = true;

    Graphical Appearance

    This property is read-only.

    Editor for the chart, specified as a Stateflow.Editor object. You can use this object to control the position, size, and magnification level of the Stateflow® Editor window.

    Whether the Stateflow Editor window is displaying the chart, specified as a numeric or logical 1 (true) or 0 (false).

    Background color for the chart, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Color for the boxes, functions, and states in the chart, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Color for transitions in the chart, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Color for junctions in the chart, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Color for the box, function, and state labels in the chart, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Font angle for the box, function, and state labels in the chart, specified as 'NORMAL' or 'ITALIC'.

    Example: chart.StateFont.Angle = 'ITALIC';

    Font weight for the box, function, and state labels in the chart, specified as 'NORMAL' or 'BOLD'.

    Example: chart.StateFont.Weight = 'BOLD;

    Initial font size for the annotation, box, function, and state labels in the chart, specified as a scalar.

    Example: chart.StateFont.Size = 8;

    Font name for the annotation, box, function, and state labels in the chart, specified as a character vector.

    Example: chart.StateFont.Name = 'Arial';

    Color for the transition labels in the chart, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Font angle for the transition labels in the chart, specified as 'NORMAL' or 'ITALIC'.

    Example: chart.TransitionFont.Angle = 'ITALIC';

    Font weight for the transition labels in the chart, specified as 'NORMAL' or 'BOLD'.

    Example: chart.TransitionFont.Weight = 'BOLD';

    Initial font size for the transition labels in the chart, specified as a scalar.

    Example: chart.TransitionFont.Size = 8;

    Font name for the transition labels in the chart, specified as a character vector.

    Example: chart.TransitionFont.Name = 'Arial';

    Hierarchy

    This property is read-only.

    Machine that contains the chart, specified as a Stateflow.Machine object.

    This property is read-only.

    Location of the chart in the model hierarchy, specified as a character vector.

    Whether the chart has changed after being opened or saved, specified as a numeric or logical 1 (true) or 0 (false).

    Whether the chart is locked, specified as a numeric or logical 1 (true) or 0 (false). Enable this property to prevent changes in the chart.

    This property is read-only.

    Whether the chart is locked, specified as a numeric or logical 1 (true) or 0 (false). This property is equivalent to the property Locked, but is used internally to prevent changes in the chart during simulation.

    Identification

    Description for the chart, specified as a character vector.

    Document link for the chart, specified as a character vector.

    User-defined tag for the chart, specified as data of any type.

    This property is read-only.

    Unique identifier, specified as an integer scalar. Use this property to distinguish the chart from other objects in the model. The value of this property is reassigned every time you start a new MATLAB session and may be recycled after an object is deleted.

    Object Functions

    classhandleProvide class handle for object
    defaultTransitionsReturn default transitions in object at top level of containment
    dialogOpen properties dialog box
    findSpecified objects in hierarchy
    fitToViewZoom in on graphical object
    getReturn MATLAB structure containing property settings of object or array of objects
    parseParse single chart or all charts in model
    setSet properties with specified values
    viewDisplay object in editing environment

    Examples

    collapse all

    Call the function sfnew to open a new Simulink model that contains an empty Stateflow chart.

    sfnew

    Access the Simulink.Root object by calling the sfroot function.

    rt = sfroot;

    Access the Stateflow.Chart object by calling the find function for the Simulink.Root object.

    chart = find(rt,'-isa','Stateflow.Chart');
    Introduced before R2006a