Main Content

getMappingForSymbol

Get mapping for symbol in atomic subchart, atomic box, or Simulink based state

Since R2022b

Description

chartSymbol = getMappingForSymbol(subsystem,subsystemSymbol) returns the main chart symbol to which the subsystem symbol subsystemSymbol maps, where subsystem is an atomic subchart, atomic box, or Simulink® based state. For more information, see Map Variables for Atomic Subcharts and Boxes and Map Variables for Simulink Based States.

example

[chartSymbol,expression] = getMappingForSymbol(subsystem,subsystemSymbol) returns the main chart symbol and the nontrivial expression to which the subsystem symbol maps.

example

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.

open_system("sf_atomic_iodata_fixed")

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

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

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

subsystemSymbol = find(subsystem.Subchart, ...
    "-isa","Stateflow.Data",Name="u1");

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

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

Check the mapping for subchart input u1.

getMappingForSymbol(subsystem,subsystemSymbol).Name
ans = 
'u1'

Map subchart input u1 to chart input u2.

setMappingForSymbol(subsystem,subsystemSymbol,chartSymbol)
getMappingForSymbol(subsystem,subsystemSymbol).Name
ans = 
'u2'

Clear the mapping for subchart input u1.

clearMappingForSymbol(subsystem,subsystemSymbol)
getMappingForSymbol(subsystem,subsystemSymbol).Name
ans = 
'u1'

Since R2023a

In a Simulink based state called Locked, modify the mapping for the output we.

Open the model sf_clutch.slx.

open_system("sf_clutch.slx")

Access the Stateflow.SimulinkBasedState object for the Simulink based state Locked.

subsystem = find(sfroot,"-isa","Stateflow.SimulinkBasedState",  ...
    Name="Locked");

Check the mapping for Simulink based state output we.

getMappingForSymbol(subsystem,"we").Name
ans = 
'we'

Map the Simulink based state output we to chart output wv.

setMappingForSymbol(subsystem,"we","wv")
getMappingForSymbol(subsystem,"we").Name
ans = 
'wv'

Clear the mapping for Simulink based state output we.

clearMappingForSymbol(subsystem,"we")
getMappingForSymbol(subsystem,"we").Name
ans = 
'we'

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

Open the model sf_atomic_parameter_fixed.slx.

open_system("sf_atomic_parameter_fixed")

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

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

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

subsystemSymbol = find(subsystem.Subchart, ...
    "-isa","Stateflow.Data",Name="T");

Check the mapping for subchart parameter T.

[~,expression] = getMappingForSymbol(subsystem,subsystemSymbol)
expression = 
'-1'

Input Arguments

collapse all

Atomic subchart, atomic box, or Simulink based state, specified as a Stateflow.AtomicSubchart, Stateflow.AtomicBox, or Stateflow.SimulinkBasedState object.

Subsystem symbol, specified as a Stateflow.Data object, a Stateflow.Event object, a string scalar, or a character vector.

Note

If the subsystem argument is a Stateflow.SimulinkBasedState object, this argument must be 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 subsystemSymbol 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 subsystemSymbol maps to a main chart symbol, expression is an empty character vector, ''.

Version History

Introduced in R2022b

expand all