Main Content

Resume Prior Substate Activity by Using History Junctions

A history junction in a state records the activity of the substates. The first time that a state that contains a history junction becomes active, the state determines which substate is active by executing the default transition. If, after a period of inactivity, the state becomes active again, the state does not execute the default transition. Instead, the substates return to the prior state of activity.

For example, in this chart, the top-level states represent the on and off modes of a lamp. The state On contains two substates, Solid and Blinking, which correspond to the two modes of operation for the lamp. When state On becomes active for the first time, the state executes the default transition and substate Solid becomes active. This substate represents the default mode of operation for the lamp. The history junction in state On records which substate is active, so that, as the chart transitions from On to Off and back to On, the last active substate becomes active once again. In other words, when you turn on the lamp, it always returns to the previous mode of operation. For more information on this example, see Design Human-Machine Interface Logic by Using Stateflow Charts.

Chart that contains a top-level state with a history junction.


A history junction can be the destination of a transition. For example, connecting an inner transition to a history junction is equivalent to drawing a self-loop transition on every substate. When the inner transition is valid, the chart exits and then immediately reenters the active substate. For more information, see Inner Transition to a History Junction.

Add a History Junction

To add a history junction to a Stateflow® chart:

  1. Open the chart.

  2. In the object palette, click the History Junction icon .

  3. On the chart canvas, click the location for the new history junction.

After you add a history junction, you can use the Stateflow Editor to change the size and position of the junction:

  • To move the junction, click and drag the junction.

  • To resize the junction, right-click the junction, select Junction Size, and choose a junction size from the drop-down list.

Specify Properties for History Junctions

You can modify the properties listed below in the Property Inspector, the Model Explorer, or the History Junction properties dialog box.

To use the Property Inspector:

  1. In the Modeling tab, under Design Data, select Property Inspector.

  2. In the Stateflow Editor, select the history junction.

  3. In the Property Inspector, edit the history junction properties.

To use the Model Explorer:

  1. In the Modeling tab, under Design Data, select Model Explorer.

  2. In the Model Hierarchy pane, select the parent state or chart for the history junction.

  3. In the Contents pane, select the history junction.

  4. In the Dialog pane, edit the history junction properties.

To use the History Junction properties dialog box:

  1. In the Stateflow Editor, right-click the history junction.

  2. Select Properties.

  3. In the properties dialog box, edit the history junction properties.

You can also modify junction properties programmatically by using Stateflow.Junction objects. For more information about the Stateflow programmatic interface, see Overview of the Stateflow API.


Parent of the history junction. This property is read-only and is not available in the Property Inspector. When you click the parent hyperlink, the Stateflow Editor brings the parent to the foreground.


Description of the history junction.

Document link

Link to online documentation for the history junction. You can enter a web URL address or a MATLAB® command that displays documentation as an HTML file or as text in the MATLAB Command Window. When you click the Document link hyperlink, Stateflow evaluates the link and displays the documentation.

See Also



Related Topics