In Simulink®, you can compare Simulink models. Review and merge differences using three-way model merge or two-way model merge.
You can use models from any version of Simulink. Use the comparison report to explore the differences, view the changes highlighted in the original models, and merge differences.
You can access the comparison tool from:
The MATLAB® Current Folder browser context menu
The MATLAB Comparison Tool
The MATLAB command line
The Simulink Editor Analysis menu
The Project view
You can use the comparison tool with both model file formats, SLX and MDL. If the
selected files are
.mdl files, or SLX files saved in a previous version,
then the comparison tool first exports the
.mdl files to SLX files in a
temporary folder, and produces a comparison report based on the SLX files.
For more information on creating reports, see Select Simulink Models to Compare.
For examples with instructions, see:
For more information on using and understanding the comparison reports, see Compare Simulink Models.
You can display comparison reports in the Comparison Tool. In the interactive report, you can click items in the report to display the corresponding items highlighted in the original models.
The comparison report shows a hierarchical view of the portions of the two files that differ. The report does not show sections of the files that are identical.
If the files are identical you see a message reporting there are no differences.
If files have not been saved, you see an error message informing you that you must save modified or newly created models before running a comparison.
It might not be possible for the analysis to detect matches between previously corresponding sections of files that have diverged too much.
Change detection is based on a scoring algorithm. Items match if their score is above a threshold. The tool's algorithm uses a comparison pattern that defines the thresholds assigned to particular node types (e.g., block).
For more information on using the report, see Compare Simulink Models.
To control highlighting, see Display Differences in Original Models.
To merge differences, see Merge Simulink Models from the Comparison Report.
For more information about the Comparison Tool, see Compare Files and Folders and Merge Files (MATLAB).
To learn what you can do with comparison reports, see About Simulink Model Comparison.
To compare files using the Simulink Editor:
Select Analysis > Compare To....
The Select Files or Folders for Comparison dialog box opens.
If the Editor currently displays a model, the current model name and path appear automatically selected in the First file or folder edit box. Use the browse buttons to locate and select files for the first and second model files.
When you click Compare, the comparison tool performs the analysis, and displays the resulting report in the Comparison Tool.
To compare two files from the Current Folder browser:
For two files in the same view, select two files, right-click and select Compare Selected Files/Folders.
Alternatively, you can browse to select the second file to compare:
Select a file, right-click and select Compare Against
Select the second file to compare in the Select Files or Folders for Comparison dialog box.
For models, leave the default Comparison type,
Simulink Model Comparison.
For more information about comparisons of other file types (e.g., text, MAT, or binary) with the Comparison Tool, see Compare Files and Folders and Merge Files (MATLAB).
If you have a project using source control, you can create a model comparison report from the Modified Files view of the project. For details, see Project Management.
To compare files using the Comparison Tool, from the MATLAB Toolstrip, in the File section, select the Compare button. In the dialog box select files to compare.
To compare XML files from the command line, enter
filename2 are XML files or
visdiff produces a report in the Comparison Tool.
To create an
xmlcomp.Edits object at the command line without
opening the Comparison Tool,
Edits = slxmlcomp.compare(modelname_A,modelname_B)
To change comparison type, either create a new comparison from the Comparison Tool, or
use the Compare Against option from the Current Folder browser.
You can change comparison type in the Select Files or Folders for Comparison dialog box.
For example, if you want the MATLAB text differences report for XML or model files, change the comparison type
Text comparison in the dialog before clicking
Compare. Alternatively, see the