MATLAB Answers


How to Automatically Compare Simulink Models

Asked by Garret Fick on 11 Dec 2017
Latest activity Commented on by Amol Koli on 17 Jun 2019
Is there a way to automatically produce a diff of Simulink models? I would like to be able to generate a report of the differences and have this shown by our code review tool so that it is possible to do simple reviews without loading the code in MATLAB.
I know it is possible to do this manually with MATLAB (see for Compare Revisions and How to Compare Models). Is this also available via the MATLAB API, and if so, could you point me to the documentation?


Sign in to comment.

1 Answer

Answer by Gavin Walker on 27 Feb 2018

You can create an HTML or Word report of the differences between two Simulink models using the ‘comparison’ output argument of the visdiff function (R2017b or newer).
For example, you can try something like this
>> comparison = visdiff(model1, model2);
>> % Publish the results of the comparison to a file:
>> reportFile = publish(comparison, 'Format', 'HTML', 'Name', 'myreport.html')
For more information, see the ‘Publish Comparison Report’ section of the visdiff documentation page:

  1 Comment

Any alternative to this solution to make this work on R2016b?

Sign in to comment.