Review Changes in Simulink Models - MATLAB & Simulink (original) (raw)
Main Content
Use the Comparison Tool to review and merge differences between two model files on disk or between different revisions of the same file.
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.
The Comparison report shows only portions of the files that differ.
Follow these steps to understand changes in your model, export comparison results for peer review, and merge differences, if required:
- Select Models to Compare
- Understand Simulink Model Comparison Changes
- Export, Print, and Save Model Comparison Results
- Port or Restore Model Changes in Comparison Report
Comparison Tool Usage Tips and Limitations
Compare Models with Identical Names
When you compare model files that have the same names as already loaded models, the Comparison Tool checks if the file paths match the already loaded models before performing a comparison. If the file paths do not match the paths of the already loaded models, to avoid shadowing issues, the Comparison Tool loads the models using different names_`modelname`__X
. For more information about shadowed files, see Shadowed Files.
To automatically close the loaded models that have the same name before performing a comparison, use these commands. The Comparison Tool only closes the models if they do not have unsaved changes.
opt = slxmlcomp.options; opt.setCloseSameNameModel(true);
MATLABĀ® stores this setting across sessions.
Compare Model Hierarchies
The Comparison Tool performs a comparison on the currently selected models only. The comparison report does not include changes to referenced models or linked libraries.
If you are comparing models that contain referenced models with the same name, check that your referenced models are not on the MATLAB path before you generate the report. Keeping referenced models with the same name on the path might result in shadowing issues and display different comparison results.
More About Model Shadowing Impact
Simulink records information in the top-level model about the interface between the top-level model and children models. This interface information in the top-level model enables incremental loading and diagnostic checks without any need to load children models.
- If you are using referenced models, when you load a top-level model, Simulink refreshes the interface information for its referenced models if the child models are on the path. The interface information results in new entries in the comparison report. To avoid these interface changes in the comparison report, make sure your referenced models are not on your path before you generate the report.
- If you are using library links only, Simulink does not update the cached interface information when comparing models. The MATLAB path does not affect the comparison report results.
- If you are using both referenced models and library links, Simulink updates the information when displaying the model. To avoid interface changes in the comparison report, make sure that the referenced models and associated libraries are temporarily removed from the path.