Main Content

Stateflow.findMatchingPort

Identify matching entry or exit port

Since R2021b

Description

matchingPort = Stateflow.findMatchingPort(port) returns a Stateflow.Port object that matches the specified port or junction.

Note

Typically, Stateflow.findMatchingPort returns a single Stateflow.Port object. However, when an entry or exit junction is located in the top level of a linked atomic subchart, Stateflow.findMatchingPort returns an array that contains a separate Stateflow.Port object for each instance of the atomic subchart that is open.

example

Examples

collapse all

In an atomic subchart called A, add an exit port and an exit junction with the label "exit".

Find the Stateflow.AtomicSubchart object that corresponds to the atomic subchart A in the chart ch.

atomicSubchart = find(ch,"-isa","Stateflow.AtomicSubchart",Name="A");

Add an exit junction to the atomic subchart. Use the Subchart property of the atomic subchart as the parent of the exit junction. Display the value of the PortType property of the exit junction.

exitJunction = Stateflow.Port(atomicSubchart.Subchart,"ExitJunction");
exitJunction.PortType
ans =

    'ExitJunction'

Set the label of the exit junction to "exit".

exitJunction.labelString = "exit";

Find the Stateflow.Port object for the matching exit port. Display the value of the PortType property of the exit port.

exitPort = Stateflow.findMatchingPort(exitJunction);
exitPort.PortType
ans =

    'ExitPort'

Display the label of the exit port.

exitPort.labelString
ans =

    'exit'

Input Arguments

collapse all

Port or junction, specified as a Stateflow.Port object.

Tips

  • If you move an entry or exit junction to a different parent, Stateflow® deletes the Stateflow.Port object for the matching port and creates a Stateflow.Port object on the new parent. To identify the new matching port, use the Stateflow.findMatchingPort function.

Version History

Introduced in R2021b