| Contents | Index |
| On this page… |
|---|
Comparison of Modeling Methods |
The following sections compare two ways of modeling similar states in charts.
You create a separate instance of each state in your chart.

In this chart, the only difference between the two states are the names of variables.
You create a single state and convert it to an atomic subchart, which you store in a new library. From that library, you can copy and paste the atomic subchart for use in any chart and update the mapping of inputs, outputs, local data, or parameters as needed.

This modeling method minimizes maintenance of similar states. When you modify the atomic subchart in the library, your changes propagate automatically to the links in all charts and models.
For more information, see Tutorial: Reusing a State Multiple Times in a Chart.
The following sections compare two ways of simulating a chart.
You make a small change to one part of a chart that contains many states or several levels of hierarchy. When you start simulation to test that change, recompilation occurs for the entire chart.
Because recompiling the entire chart takes a long time, you make several changes before testing. However, if you find an error, you must step through all your changes to identify what causes the error.
You make a small change to an atomic subchart in a chart that contains many states or several levels of hierarchy. When you start simulation to test that change, recompilation occurs only for the atomic subchart.
Incremental builds for simulation decrease the time required to recompile the chart. This reduction enables you to test each change, one by one, instead of waiting to test multiple changes. By testing each change individually, you can quickly identify a change that causes an error.
For more information, see Tutorial: Reducing the Compilation Time of a Chart.
The following sections compare two ways of editing a chart.
You edit one part of a chart, while someone else edits another part of the same chart. At submission time, you merge your changes with someone else's edits.
You store one part of a chart as an atomic subchart in a library. You edit that subchart separately, while someone else edits the main chart. At submission time, no merge is necessary because the changes exist in separate models.
For more information, see Tutorial: Dividing a Chart into Separate Units for Editing.
The following sections compare two ways of generating code.
You generate code for the entire model in one file and look through that entire file to find code for a specific part of the chart.

You specify code generation parameters so that code for an atomic subchart appears in a separate file.

This method of code generation enables unit testing for a specific part of a chart. You can avoid searching through unrelated code and focus only on the part that interests you.
For more information, see Tutorial: Generating Reusable Code for Unit Testing.
![]() | When to Use Atomic Subcharts | Restrictions for Converting to Atomic Subcharts | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |