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:

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

    Properties

    expand all

    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

    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.

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

    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

    This property applies only when the Debug.Animation.Enable property of the machine is true.

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

    This property is read-only.

    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.MaintainHighlighting = true;

    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 character vector.

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

    Version of the machine, specified as a character vector.

    Description for the machine, specified as a character vector.

    Document link for the machine, specified as a 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

    classhandleProvide class handle for object
    dialogOpen properties dialog box
    findSpecified objects in hierarchy
    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

    Examples

    collapse all

    Update the Modified and Version properties of machine machine.

    machine.Modified = string(datetime);
    oldVersion = str2num(machine.Version);
    if isempty(oldVersion) 
        machine.Version = '1';
    else
        machine.Version = num2str(oldVersion+1);
    end
    Introduced before R2006a