Main Content

renameReferences

Rename symbol and update references to symbol name

Since R2023a

Description

renameReferences(symbol,newName) changes the name of symbol to newName and updates the references to the symbol name in the chart. Symbols include Stateflow.Data, Stateflow.Event, Stateflow.Message, and other Stateflow® objects that have a Name property.

example

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;'}

Input Arguments

collapse all

New name for the symbol, specified as a string scalar or a character vector.

Limitations

  • The functions getReferences and renameReferences do not find or update references to exported functions in other charts, atomic subcharts, or Function Caller (Simulink) blocks.

Version History

Introduced in R2023a