Main Content

setMappingForSymbol

Set mapping for symbol in atomic subchart or box

Description

example

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

example

setMappingForSymbol(subchart,subchartSymbolName,chartSymbolName) maps the symbol named subchartSymbolName to the main chart symbol named chartSymbolName.

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'

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.

Main chart symbol, 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.

Name of main chart symbol, specified as a string scalar or character vector.

Limitations

  • The setMappingForSymbol function only supports mapping symbols in atomic subcharts and boxes to main chart symbols. To map a symbol to an expression, use the Mappings tab of the properties dialog box. For more information, see Map Atomic Subchart Parameters to Expressions.

Version History

Introduced in R2022b