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.

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.

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 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 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.

Explore Differences in 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 "Always Highlight" 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. If you are merging many changes in a MATLAB Function, it can be helpful to turn off highlighting in models using the View tab.

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 Files

Was this topic helpful?