Main Content

Stateflow.SymbolReference

Reference to symbol name

Since R2023a

    Description

    Stateflow.SymbolReference objects indicate where a Stateflow® chart refers to a symbol name. For example, a Stateflow.SymbolReference object can correspond to a state or transition action that includes a symbol name. Symbols include Stateflow.Data, Stateflow.Event, Stateflow.Message, and other Stateflow objects that have a Name property.

    Creation

    The Stateflow chart maintains an array of Stateflow.SymbolReference objects for each symbol. To access this array, call the object function getReferences.

    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.

    This property is read-only.

    Object that references the symbol name, specified as a Stateflow API object of one of these types:

    This property is read-only.

    Position of the symbol name, specified as a two-element integer vector of the form [start end] or as an empty vector.

    • If WhereUsed is a Stateflow.State or Stateflow.Transition object, the values of start and end indicate the positions of the first and last characters of the symbol name in the LabelString property of WhereUsed.

    • If WhereUsed is a Stateflow.EMFunction object, the values of start and end indicate the positions of the first and last characters of the symbol name in the Script property of WhereUsed.

    • If WhereUsed is an object of any other type, this property is an empty vector.

    Examples

    collapse all

    Rename and update the references to the chart output y.

    api_rectify_chart_05.png

    Open the model and access the Stateflow.Data object for the chart output y.

    open_system("sfRectifyAPIExample")
    data = find(sfroot,"-isa","Stateflow.Data",Scope="Output");
    data.Name
    ans = 
    'y'
    

    Find the locations where the chart refers to the chart output.

    references = getReferences(data)
    references=2×1 SymbolReference array with properties:
        Position
        WhereUsed
    
    

    Display the names and entry actions of the states that refer to the chart output.

    whereUsed = [references.WhereUsed];
    classes = arrayfun(@class,whereUsed,UniformOutput=false);
    idx = (classes=="Stateflow.State");
    states = whereUsed(idx);
    get(states,{"Name" "EntryAction"})
    ans = 2x2 cell
        {'On' }    {'y = x;'}
        {'Off'}    {'y = 0;'}
    
    

    Change the Name property of the chart output to "z" and update the references to the output in the chart.

    renameReferences(data,"z")
    data.Name
    ans = 
    'z'
    

    Display the names and modified entry actions of the states that refer to the chart output.

    get(states,{"Name" "EntryAction"})
    ans = 2x2 cell
        {'On' }    {'z = x;'}
        {'Off'}    {'z = 0;'}
    
    

    Version History

    Introduced in R2023a