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:
MATLAB® Home tab — In the File section, click Compare. Then, select the models you want to compare.
Current Folder browser or Project Files browser — To compare a model to another model on disk, right-click the selected model file and select Compare Against. Alternatively, select and right-click two model files, and then select Compare Selected Files/Folders.
Simulink Editor — To compare a model that is open in the Editor to another model on disk, on the Modeling tab, in the Evaluate & Manage section, click Compare To.
Command Window — Use the
visdiff
function.
For models under source control, you can open the Comparison Tool to understand differences between revisions using one of the following methods.
Current Folder browser or Project Files browser — To compare a model to its ancestor or to a different revision, right-click the model file and select Source Control > Compare to Ancestor or Source Control > Compare to Revision.
Branch Browser — To inspect changes in a model between two Git™ revisions, open the Branch Browser, right-click and select Source Control > Branches. In the right pane of the Branch Browser, right-click a model and select Show Difference.
Examples
Related Examples
Parameters
Programmatic Use
Limitations
MATLAB Online™ does not support creating custom filters in model comparison reports.
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.
Version History
Introduced in R2008b