Main Content

getMappingForSymbol

Get mapping for symbol in atomic subchart or box

Description

example

chartSymbol = getMappingForSymbol(subchart,subchartSymbol) returns the main chart symbol to which the symbol subchartSymbol in the atomic subchart or box subchart maps. For more information, see Map Variables for Atomic Subcharts and Boxes.

example

chartSymbol = getMappingForSymbol(subchart,subchartSymbolName) returns the main chart symbol to which the subchart symbol named subchartSymbolName maps.

example

[chartSymbol,expression] = getMappingForSymbol(___) returns the main chart symbol and the nontrivial expression to which the subchart symbol maps. Specify the subchart symbol using one of the previous syntaxes.

Examples

collapse all

In an atomic subchart called A, modify the mapping for the subchart input u1.

Open the model sf_atomic_iodata_fixed.slx.

openExample('stateflow/AtomicSubchartInOutDataExample', ...
    SupportingFile="sf_atomic_iodata_fixed.slx")

Access the Stateflow.AtomicSubchart object for the atomic subchart A.

subchart = find(sfroot,"-isa","Stateflow.AtomicSubchart",Name="A");

Use the Subchart property to access the Stateflow.Data object for subchart input u1.

subchartSymbol = find(subchart.Subchart, ...
    "-isa","Stateflow.Data",Name="u1");

Use the Chart property to access the Stateflow.Data object for chart input u2.

chartSymbol = find(subchart.Chart, ...
    "-isa","Stateflow.Data",Name="u2");

Get the mapping for subchart input u1.

getMappingForSymbol(subchart,subchartSymbol).Name
ans =

    'u1'

Map subchart input u1 to chart input u2.

setMappingForSymbol(subchart,subchartSymbol,chartSymbol)
getMappingForSymbol(subchart,subchartSymbol).Name
ans =

    'u2'

Clear the mapping for subchart input u1.

clearMappingForSymbol(subchart,subchartSymbol)
getMappingForSymbol(subchart,subchartSymbol).Name
ans =

    'u1'

In an atomic subchart called A, modify the mapping for the subchart output y1.

Open the model sf_atomic_iodata_fixed.slx.

openExample('stateflow/AtomicSubchartInOutDataExample', ...
    SupportingFile="sf_atomic_iodata_fixed.slx")

Access the Stateflow.AtomicSubchart object for the atomic subchart A.

subchart = find(sfroot,"-isa","Stateflow.AtomicSubchart",Name="A");

Get the mapping for subchart output y1.

getMappingForSymbol(subchart,"y1").Name
ans =

    'y1'

Map subchart output y1 to chart output y2.

setMappingForSymbol(subchart,"y1","y2")
getMappingForSymbol(subchart,"y1").Name
ans =

    'y2'

Clear the mapping for subchart output y1.

clearMappingForSymbol(subchart,"y1")
getMappingForSymbol(subchart,"y1").Name
ans =

    'y1'

In an atomic subchart called A, find the expression that the parameter T maps to.

Open the model sf_atomic_parameter_fixed.slx.

openExample('stateflow/AtomicSubchartParameterExample', ...
    SupportingFile="sf_atomic_parameter_fixed.slx")

Access the Stateflow.AtomicSubchart object for the atomic subchart A.

subchart = find(sfroot,"-isa","Stateflow.AtomicSubchart",Name="A");

Use the Subchart property to access the Stateflow.Data object for subchart parameter T.

subchartSymbol = find(subchart.Subchart, ...
    "-isa","Stateflow.Data",Name="T");

Get the mapping for subchart parameter T.

[~,expression] = getMappingForSymbol(subchart,subchartSymbol)
expression =

    '-1'

Input Arguments

collapse all

Atomic subchart or box, specified as a Stateflow.AtomicSubchart or Stateflow.AtomicBox object.

Symbol in atomic subchart or box, specified as a Stateflow.Data or Stateflow.Event object.

Name of symbol in atomic subchart or box, specified as a string scalar or character vector.

Output Arguments

collapse all

Main chart symbol, returned as a Stateflow.Data object, a Stateflow.Event object, or an empty array []. If the subchart symbol maps to a nontrivial expression, chartSymbol is an empty array.

Mapping expression, returned as a character vector. This expression can specify:

  • A field of a Stateflow® structure

  • An element of a vector or matrix

  • Any combination of structure fields or matrix indices

If the subchart symbol maps to a main chart symbol, expression is an empty character vector, ''.

Version History

Introduced in R2022b