Main Content

Stateflow.AtomicSubchart

Atomic subchart in chart, state, or box

    Description

    Use Stateflow.AtomicSubchart objects to create independent subcomponents in a Stateflow® chart. Atomic subcharts allow for:

    • Reuse of the same state or subchart across multiple charts and models

    • Faster simulation after making small changes to a chart with many states or levels of hierarchy

    • Ease of team development when multiple people are working on different parts of the same chart

    • Manual inspection of generated code for a specific state or subchart in a chart

    For more information, see Create Reusable Subcomponents by Using Atomic Subcharts.

    Creation

    Description

    example

    atomicSubchart = Stateflow.AtomicSubchart(parent) creates a Stateflow.AtomicSubchart object in a parent chart, state, or box.

    Input Arguments

    expand all

    Parent for the new atomic subchart, specified as a Stateflow API object of one of these types:

    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

    Name of the atomic subchart, specified as a character vector.

    Label for the atomic subchart, specified as a character vector.

    This property is read-only.

    Whether the atomic subchart is a library link, specified as a numeric or logical 1 (true) or 0 (false).

    Whether to comment out the atomic subchart, specified as a numeric or logical 1 (true) or 0 (false). Setting this property to true is equivalent to right-clicking the atomic subchart and selecting Comment Out. For more information, see Commenting Stateflow Objects in a Chart.

    This property is read-only.

    Whether the atomic subchart is implicitly commented out, specified as a numeric or logical 1 (true) or 0 (false). The atomic subchart is implicitly commented out when you comment out a state or box that contains it.

    Comment text for the atomic subchart, specified as a character vector. This property applies only when the IsExplicitlyCommented property is true. In the Stateflow Editor, when you point to the comment badge on the atomic subchart, the text appears as a tooltip. When you set the IsExplicitlyCommented property to false, the value of CommentText reverts to ''.

    Graphical Appearance

    Position and size of the atomic subchart, specified as a four-element numeric vector of the form [left top width height].

    This property is read-only.

    Whether the atomic subchart graphically intersects a box, state, or function, specified as a numeric or logical 1 (true) or 0 (false).

    Whether to display a preview of the atomic subchart contents, specified as a numeric or logical 1 (true) or 0 (false).

    Size of incoming transition arrows, specified as a scalar.

    Font size for the atomic subchart label, specified as a scalar. The StateFont.Size property of the chart that contains the atomic subchart sets the initial value of this property.

    State Decomposition

    This property is read-only.

    Decomposition of sibling states, specified as 'OR' or 'AND'. The atomic subchart inherits this property from the Decomposition property of its parent state or chart.

    Execution order for the atomic subchart in parallel (AND) decomposition, specified as an integer scalar. This property applies only when both of these conditions are satisfied:

    • The Type property of the atomic subchart is 'AND'.

    • The UserSpecifiedStateTransitionExecutionOrder property of the chart that contains the atomic subchart is true.

    Active State Output

    Whether to create an active state data output port for the atomic subchart, 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 atomic subchart, specified as a Stateflow.Data object. This property applies only when the HasOutputData property for the atomic subchart is true.

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

    Monitoring mode for the active state output data, specified as a character vector. For atomic subcharts, the only option is 'SelfActivity'.

    Signal Logging

    Signal logging properties for the atomic subchart, specified as a Stateflow.SigLoggingInfo object with these properties:

    • DataLogging — Whether to enable signal logging, specified as a numeric or logical 1 (true) or 0 (false).

    • DecimateData — Whether to limit the amount of logged data, specified as a numeric or logical 1 (true) or 0 (false).

    • Decimation — Decimation interval, specified as an integer scalar. This property applies only when the DecimateData property is true.

    • LimitDataPoints — Whether to limit the number of data points to log, specified as a numeric or logical 1 (true) or 0 (false).

    • MaxPoints — Maximum number of data points to log, specified as an integer scalar. This property applies only when the LimitDataPoints property is true.

    • NameMode — Source of the signal name, specified as 'SignalName' or 'Custom'.

    • LoggingName — Custom signal name, specified as a character vector. This property applies only when the NameMode property is 'Custom'.

    For more information, see Log Simulation Output for States and Data.

    Example: state.LoggingInfo.DataLogging = true;

    Debugging

    Debugger properties for the state, atomic subchart, or Simulink® based state, specified as a Stateflow.StateDebug object with these properties:

    • OnEntry — Whether to set the On State Entry breakpoint, specified as a numeric or logical 1 (true) or 0 (false).

    • OnDuring — Whether to set the During State breakpoint, specified as a numeric or logical 1 (true) or 0 (false).

    • OnExit — Whether to set the On State Exit breakpoint, specified as a numeric or logical 1 (true) or 0 (false).

    For more information, see Set Breakpoints to Debug Charts.

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

    Example: atomicSubchart.Debug.Breakpoints.OnDuring = true;

    Example: atomicSubchart.Debug.Breakpoints.OnExit = true;

    Whether to set the atomic subchart as a test point, specified as a numeric or logical 1 (true) or 0 (false).

    Hierarchy

    This property is read-only.

    Chart that contains the atomic subchart, specified as a Stateflow.Chart object.

    This property is read-only.

    Contents of the atomic subchart, specified as a Stateflow.Chart object. Use this object to add children, such as states and transitions, to the atomic subchart. For more information, see Add Exit Port and Junction to Atomic Subchart.

    This property is read-only.

    Subviewer for the atomic subchart, specified as a Stateflow.Chart, Stateflow.State, or Stateflow.Box object. The subviewer is the chart or subchart where you can graphically view the atomic subchart.

    This property is read-only.

    Machine that contains the atomic subchart, specified as a Stateflow.Machine object.

    This property is read-only.

    Location of the parent of the atomic subchart in the model hierarchy, specified as a character vector.

    Identification

    Description for the atomic subchart, specified as a character vector.

    Document link for the atomic subchart, specified as a character vector.

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

    This property is read-only.

    Session-independent identifier, specified as an integer scalar. Use this property to distinguish the atomic subchart from other objects in the model.

    This property is read-only.

    Unique identifier, specified as an integer scalar. Unlike SSIdNumber, 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

    getParentIdentify parent of object
    dialogOpen properties dialog box
    isCommentedDetermine if graphical object is commented out
    viewDisplay object in editing environment
    highlightHighlight graphical object
    fitToViewZoom in on graphical object

    Examples

    collapse all

    Add an atomic subchart in the chart ch. Set its name to 'A'.

    atomicSubchart = Stateflow.AtomicSubchart(ch);
    atomicSubchart.Name = 'A';

    Find the Stateflow.AtomicSubchart object that corresponds to the atomic subchart A in the chart ch.

    atomicSubchart = find(ch,'-isa','Stateflow.AtomicSubchart','Name','A');

    Add an exit junction to the atomic subchart. Use the Subchart property of the atomic subchart as the parent of the exit junction. Display the value of the PortType property of the exit junction.

    exitJunction = Stateflow.Port(atomicSubchart.Subchart,'ExitJunction');
    exitJunction.PortType
    ans =
    
        'ExitJunction'

    Set the label of the exit junction to 'exit'.

    exitJunction.labelString = 'exit';

    Find the Stateflow.Port object for the matching exit port. Display the value of the PortType property of the exit port.

    exitPort = Stateflow.findMatchingPort(exitJunction);
    exitPort.PortType
    ans =
    
        'ExitPort'

    Display the label of the exit port.

    exitPort.labelString
    ans =
    
        'exit'
    Introduced in R2010b