This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Merge Simulink Models From the Comparison Report

This example shows you how to use Simulink® Report Generator™ to compare XML files from two Simulink models. You can view and merge the Simulink and Stateflow® XML differences in the resulting report.

This example shows you how to use Simulink Report Generator XML comparison to understand what has changed between two different designs. The designs are based upon the Simulink and Stateflow model sf_car. Some development work has added a new "kickdown" mode to the shift logic. You can use the Simulink Report Generator to compare XML files from the two models and produce a report for exploring and merging the differences.

Compare The XML Files

Run the following commands to compare XML files from the models.

visdiff('slxml_sfcar_1', 'slxml_sfcar_2')

Understand The Results

The Comparison Tool shows a report that only includes the differences between the two XML files, not the complete hierarchy of the XML files.

Colors indicate if items are modified (pink items) or unmatched (green items, found only on one side).

Stepping Through Differences

Use the "Next" and "Previous" navigation buttons on the Comparison tab to step through groups of changes in the report. When you do this to select an item:

  • The report highlights the corresponding item in the other tree (if it exists).

  • Both models display next to the report. The report highlights the corresponding item in the Simulink model, if possible.

You can control highlighting in models on the View tab.

Highlight Differences in the Simulink Models

Click to select the tree node "Out1" in the left hand side tree. Observe the report highlights "Out1" in the report, and the corresponding block in the model "slxml_sfcar_1".

Highlight Differences in a Stateflow Chart

Now browse down the tree to locate the Stateflow part of the report. Observe the Stateflow icon next to the "Stateflow" node and the Stateflow chart icon next to the "shift_logic" node. Click "kickdown" in the left tree. The report displays both "shift_logic" Stateflow charts. Observe where the new "kickdown" functionality has been added to one of the charts.

Filtering Results

It is possible to filter the results shown in the Comparison Tool to remove items that are not of interest. To see the available filters, and whether or not they have been applied to the current report, click the Filter button on the View tab.

Some information in the Simulink XML 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.

Merging Nodes

You can merge nodes from the left (source) model to the right (target) model. The steps below merge all changes associated with the new "kickdown" mode to the target model.

To simplify the report and make sure you can see your merges in the original models, select the View tab and check that:

  • "Hide nonfunctional changes" is selected under the Filter button.

  • "Always Highlight" check box is selected.

To merge Stateflow changes you must first merge Stateflow states and junctions and then merge transitions.

1. Locate and select the "gear_state" node in the Stateflow part of the report. Notice the Merge Node button in the Merge section on the Comparison tab is enabled.

2. Click the Merge Node button to merge the node.

The report marks the Stateflow "gear_state" nodes as merged (grey) and the icons have a green arrow to indicate a merge. All changes below the merged nodes are removed from the report, because all changes in the "gear_state" Stateflow state in the left model are merged into the "gear_state" Stateflow state in the right model. The report highlights all merged changes in the "shift_logic" charts.

3. Next, select the "kickdown" node under the "selection_state" node on the left side of the report.

4. Click the Merge Node button.

The report marks the "kickdown" node as merged and inserts an equivalent node in the right hand side hierarchy. Observe the "kickdown" state has been added to the "shift_logic" chart in the target model. "kickdown" is highlighted in both charts.

5. Now select the last "junction" node at the bottom of the left tree and merge. Observe the merge changes in the report and Stateflow charts.

6. To complete the merge and connect up the "kickdown" state, you need to merge all transition nodes under "selection_state". Look for transition icons, with the tooltip "Transition". Merge each node in turn.

As you merge each transition, the report connects the appropriate objects in the target model. Note that you must merge Stateflow states and junctions before merging transitions or the connections cannot be made. The same ordering is true for blocks and lines in the Simulink domain, where blocks must be merged before lines.

Further Information

Compare Simulink Model XML Files

Was this topic helpful?