Main Content

Divide a Chart into Separate Units

This example shows how to use linked atomic subcharts to break a Stateflow® chart into subcomponents so that multiple people can work on different parts of the chart. Atomic subcharts are supported only in Stateflow charts in Simulink® models. For more information, see Create Reusable Subcomponents by Using Atomic Subcharts.

Original Model Without Atomic Subcharts

This model contains two Sine Wave blocks: one with a frequency of 1 radian per second, and the other with a frequency of 2 radians per second.

In the chart, each state uses saturator logic to convert the input sine wave to an output square wave of the same frequency.

Because this example does not use atomic subcharts, only one person at a time can edit the model. If you edit state A while someone else edits state B, you must merge those changes at submission time.

In contrast, you can store different parts of this example as linked atomic subcharts. Because atomic subcharts behave as independent objects, different people can work on different parts of a chart without affecting the other parts of the chart. At submission time, no merge is necessary because the changes exist in separate models.

Edit Model to Use Atomic Subcharts

Step 1: Convert a State to an Atomic Subchart

Right-click state A and select Group & Subchart > Atomic Subchart. State A changes to an atomic subchart and displays the label Atomic in the upper-left corner.

Step 2: Create a Library for the Atomic Subchart

  1. Create a new library model.

  2. Copy the atomic subchart and paste it in your library model.

  3. Save your library model.

In the library model, the atomic subchart appears as an independent chart with an input port and an output port.

Step 3: Replace State with Linked Atomic Subchart

  1. Delete state A in the chart.

  2. Copy the atomic subchart in your library and paste it in your chart.

The linked atomic subchart appears opaque and contains the label Link in the upper-left corner.

Propagate a Change in the Library Chart

Suppose that, in the library chart, you edit the transition from Pos to Neg.

This change propagates to the linked atomic subchart in the main chart. If someone else edits the main chart, the changes are merged automatically.

See Also

Related Topics