Main Content

setMappingForSymbol

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

Since R2022b

Description

example

setMappingForSymbol(subsystem,subsystemSymbol,chartSymbol) maps the subsystem symbol subsystemSymbol to the main chart symbol chartSymbol, 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.

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'

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.

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

Limitations

  • The setMappingForSymbol function does not support mapping symbols in atomic subcharts and atomic boxes to expressions.

Version History

Introduced in R2022b

expand all