Comparison Tool
Diff and merge changes between Simulink models
Description
The Comparison Tool in Simulink® is an interactive tool for visualizing and merging differences between two Simulink models.
In a collaborative environment, you typically compare models:
When you require a peer review of your changes
Before you share or submit a version of your code to source control
When you want to pinpoint when an issue was introduced
When you want to examine your own local changes in detail
Using the Comparison Tool, you can:
Compare and review changes in SLX and MDL model files from any version of Simulink. If needed, the Comparison Tool resaves the models in the current release using the SLX format before opening the comparison report.
Visualize and highlight changes in the Simulink Editor.
Export the comparison results to send for peer review.
Use merge mode to port or restore changes in different models.
Open the Comparison Tool
You can select files and folders on disk to compare using one of these methods:
Simulink Editor — To compare a model that is open in the Simulink Editor to another model on disk, on the Modeling tab, in the Evaluate & Manage section, click Compare To.
Files or Project panel — To compare two files on disk, select both files. Then, right-click and select Compare Selected Files/Folders. The Comparison Tool opens both files, with the file you selected first on the left.
Alternatively, right-click a file and select Compare To. Then, select the file you want to compare to.
Command Window — Use the
visdiff
function.
For files under source control, you can open the Comparison Tool to understand differences between revisions using one of the following methods.
Files or Project panel — To compare a file to its ancestor, right-click the file and select Source Control > View Changes. To compare the file to a different revision, right-click the model file and select Show Revisions. In the Log dialog box, select the revision and click Compare to Local.
Source Control panel — To compare a file to its ancestor, in the Modified Files section, right-click the file and select View Changes. To compare the file to a different revision, right-click the file and select Show Revisions. In the Log dialog box, select the revision and click Compare to Local.
Branch Manager — To inspect changes in a file between two Git™ revisions, open the Branch Manager. Right-click and select Source Control > Branch Manager. In the Commit Differences pane, right-click a file and select Show Differences.
Examples
Related Examples
Parameters
Programmatic Use
More About
Algorithms
To match items between one Simulink model and another, the Comparison Tool uses a heuristic algorithm that relies on various model properties, including block and line connectivity, location, and parameters. A heuristic algorithm decreases the cost of computationally expensive model comparison analysis by proposing a match that balances efficiency and accuracy.
Note
The analysis might not be able to detect matches between previously corresponding sections of files that have diverged.