This example shows how to use the comparison report in MATLAB® to understand what has changed between two different designs. It shows how to view and merge the changes between two Simulink® models containing Stateflow® using the comparison report. A Stateflow license is required to run this example.
Create a working copy of the example files. MATLAB® copies the files to an example folder so that you can edit them.
A user added a new
kickdown mode to the
shift_logic. You can use the Simulink Model Comparison to compare the two models and produce a report to explore and merge the differences.
visdiff to compare the
The Comparison Tool shows a report that only includes the differences between the two models, not the complete model hierarchies.
Colors indicate if items have been modified (purple), inserted (blue), or deleted (yellow).
Use the Next and Previous navigation buttons on the Comparison tab to step through groups of changes in the report:
The report goes through the changes one by one. If the selected item in the Left tree has a match, it will also be selected in the Right tree.
MATLAB displays both models next to the report. The report highlights the selected items in both Simulink models if it is possible.
Select the tree node
Out1 in the Right tree. Observe the report highlights
Out1 in the report, and the corresponding block in the model
To control highlighting in models, on the Comparison tab, in the Highlight section, select or clear the check box Always Highlight. You can click the Highlight Now button to highlight the currently selected report node at any time.
Browse down the tree to locate the Stateflow charts in the report. Observe the Stateflow chart icon next to the
shift_logic node. Click
kickdown in the Right tree. The report displays both
shift_logic Stateflow charts. Observe where the new
kickdown functionality has been added to one of the charts.
You can control the type of changes displayed in the comparison report by applying filters. To see the available filters and whether or not they are applied to the current report, on the Comparison tab, in the Filter section, click the down arrow to expand the filter gallery. Click filter names to toggle whether they are applied. In the Filter section, click Show or Hide to control how the filters are applied.
For example, some information in the Simulink model file is defined as being nonfunctional. These are changes that are unlikely to change the behavior of the design. Nonfunctional items are hidden by default. You can show them by deselecting the Nonfunctional Changes button when the Hide filter button is selected.
You can merge the changes between the two Simulink and Stateflow models by clicking the Merge Mode button in the toolstrip. This creates a third file,
targetFile, which can contain the changes from either the left model or right model. Use the buttons in the Target tree to select the differences to keep in the
Click the Save File button to save the changes you selected over the right model (
You must merge blocks before lines in the Simulink part of the report. You must merge states and junctions before merging transitions, or the report cannot make the connections.
For information on merging between models with identical names, see Comparing Models with Identical Names.