Documentation Center

  • Trials
  • Product Updates

Simulink XML Comparison

This example shows you how to use Simulink® Report Generator™ to compare XML files from two Simulink models. You can view the Simulink 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 model sldemo_radar_matlab_function. The model has been modified to remove the use of "persistent" variables within the MATLAB® function and replace them with unit delay blocks. You can use the Simulink Report Generator to compare XML files from the two models and produce a report for exploring the differences. Run the following commands to open the two example models:

open_system('slxml_radar_matlab_function_1')
open_system('slxml_radar_matlab_function_2')

Compare The XML Files

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

visdiff('slxml_radar_matlab_function_1', 'slxml_radar_matlab_function_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 displays a "reverse annotation" from the report to the corresponding item in the Simulink model, if possible, using the Simulink "hilite_system" function.

You can toggle reverse annotation on and off by selecting the "Highlight in Models" check box on the View tab.

Use Reverse Annotation to a Simulink Model

Click to select the first instance of "MATLAB Function" in the left tree. Observe the report highlights "MATLAB Function" on both sides of the report, and the corresponding block in both the Simulink models.

Use Reverse Annotation to a MATLAB Function Block

Now browse down the left tree to the MATLAB Function Stateflow® chart node. Locate the pink node under this node, also named "MATLAB Function". Click the "Compare" button at the end of this node to open a new instance of the Comparison Tool comparing the two MATLAB functions. In this example you can see that the input and arguments of the function have changed, and the persistent variables have been deleted in slxml_radar_matlab_function_2.

Merge Changes in a MATLAB Function Block

You can choose to merge individual changes back to the original script. To do this select a difference in the report, and click the merge button on the Comparison tab. If "Highlight in Models" is on, this shows the parent report. Click Compare again to return to the text comparison of the MATLAB Functions and view the merged node. You may want to turn off highlighting in models if you are merging many changes in a MATLAB Function.

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.

Further Information

Compare Simulink Model XML FilesCompare Simulink Model XML Files

Was this topic helpful?