Main Content

Stateflow.Machine

Container for Stateflow blocks in a Simulink model

    Description

    From a Stateflow® perspective, Stateflow.Machine objects are equivalent to Simulink® models. A Stateflow.Machine object contains Stateflow.Chart, Stateflow.StateTransitionTableChart, Stateflow.TruthTableChart, and Stateflow.EMChart objects that represent the Stateflow charts, State Transition Table blocks, Truth Table blocks, and MATLAB Function blocks in a Simulink model. For more information, see Overview of the Stateflow API.

    Creation

    You automatically create a Stateflow.Machine object when you load a model that contains a Stateflow block or call the function sfnew. To access the Stateflow.Machine object, call the find function for the Simulink.Root object. For example, if your Simulink model is named myModel, enter:

    machine = find(sfroot,"-isa","Stateflow.Machine",Name="myModel");

    Properties

    expand all

    Stateflow API objects have properties that correspond to the values you set in the Stateflow Editor. To access or modify a property, use dot notation. To access or modify multiple properties for multiple API objects, use the get and set functions, respectively. For more information, see Modify Properties and Call Functions of Stateflow Objects.

    Content

    This property is read-only.

    Name of the Simulink model for the machine, specified as a character vector.

    This property is read-only.

    Full file path of the Simulink model for the machine, specified as a character vector.

    This property is read-only.

    Whether the Simulink model for the machine builds a library and not an application, specified as a numeric or logical 1 (true) or 0 (false).

    Debugging

    Debugger properties for charts in the machine, specified as a Stateflow.MachineDebug object with these properties:

    • Animation.Enabled — Whether to animate the charts in the machine during simulation, specified as a numeric or logical 1 (true) or 0 (false). Disabling this property is equivalent to selecting None in the Animation Speed drop-down list in the Debug tab.

    • Animation.Delay — Delay that the chart animation uses for highlighting each transition segment in the machine, specified as a scalar. These values correspond to the settings of the Animation Speed drop-down list in the Debug tab:

      Delay ValueAnimation Speed
      0.5Slow
      0.2Medium
      0Fast
      -1Lightning Fast

    • Animation.MaintainHighlighting — Whether to maintain the highlighting of active states in the machine after the simulation ends, specified as a numeric or logical 1 (true) or 0 (false).

    Example: machine.Debug.Animation.Enabled = true;

    Example: machine.Debug.Animation.Delay = -1;

    Hierarchy

    This property is read-only.

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

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

    Whether the machine is locked, specified as a numeric or logical 1 (true) or 0 (false). Enable this property to prevent changes in the Stateflow charts, state transition tables, and truth table blocks in this machine.

    This property is read-only.

    Whether the machine 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 machine during simulation.

    Identification

    This property is read-only.

    Date of the creation of the machine, specified as a character vector.

    Creator of the machine, specified as a string scalar or character vector.

    Record of modifications to the machine, specified as a string scalar or character vector.

    Version of the machine, specified as a string scalar or character vector.

    Description for the machine, specified as a string scalar or character vector.

    Document link for the machine, specified as a string scalar or character vector.

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

    This property is read-only.

    Unique identifier, specified as an integer scalar. Use this property to distinguish the machine 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

    findIdentify specified objects in hierarchy
    dialogOpen properties dialog box

    Examples

    collapse all

    Update the Modified and Version properties of machine machine.

    machine.Modified = string(datetime);
    oldVersion = str2double(machine.Version);
    if isnan(oldVersion) 
        machine.Version = "1";
    else
        machine.Version = string(oldVersion+1);
    end

    Version History

    Introduced before R2006a