Diff between Simulink models .slx
Asked Answered
U

4

9

I am using Git and I am using MATLAB/Simulink.

I know that there is some kind of integration in the new versions of MATLAB/Simulink with Git but I was wondering if there is an easy way to read a git diff between 2 Simulink models which are of the format .slx

This can be useful when, for example, you have a simulink model in which you have a so-called MATLAB Embedded Function and you want to understand what the differences are between the functions in different versions of your software.

It can be also useful to understand the blocks which were commented and all the differences between two different Simulink models (.slx).

Undercut answered 18/12, 2015 at 13:5 Comment(0)
U
15

I found a solution to my problem.

  1. If you are in your repository you MUST have a .git folder.
  2. Go to this folder and open the file config (create it if it is not available, but it should be there normally).
  3. Add the following code to the file:

    [diff "slx"]
    textconv = unzip -c -a
    
  4. Then you need to create or modify the file REPOSITORY/.gitattributes and add:

    *.slx diff=slx
    

In this way when you do a git diff on a Simulink model (.slx) you will have a quite readable result.

I hope it will help someone else.

Undercut answered 18/12, 2015 at 13:10 Comment(5)
MathWorks also offer a model comparison through XML files generated from the models using Simulink Report Generator, see: uk.mathworks.com/help/rptgenext/model-comparison.htmlAstor
Yes I know. To use that you should go the creation of a so-called SIMULINK project. I didn't want to do that. But it is just a matter of taste.Undercut
This might work, but as the Simulink file format is not documented, you run the risk of it not working when you switch version/release or when you compare two models created in different releases of MATLAB.Astor
Upvote on this, it's amazing... :) Is there any way to do this for direct file viewing of the folder as well? Doing this with Git Extensions works perfectly to have it unzip when using the built-in diff tool, but when viewing the file directly, it does not unzip first...Antirachitic
For step 3 you can use the git syntax: git config --local diff.slx.textconv "unzip -c -a"Extensity
D
4

Whilst a text comparison can give some idea of what has changed for simple changes, the information that goes to into a Simulink model is stored in a variety of places with the SLX container. A tool like the Simulink Comparison features within the Simulink Report Generator can give much more insight into what has changed, as well as allowing operations like merge.

Simulink has had Git integration, via a Simulink Project, since R2014a, or via the MATLAB Current Folder tool since R2014b.

Dneprodzerzhinsk answered 19/12, 2015 at 18:37 Comment(0)
V
3

There are commercial tools that can perform a diff of Simulink models, some can even merge them too. The Mathworks tool was mentioned in the comments of another answer, but there are other tools such as SimDiff that can integrate with Git directly.

Disclaimer: I work for the company that makes SimDiff

Verified answered 27/9, 2017 at 17:1 Comment(3)
Thanks for the answer. Could you highlight or point out what are the differences between SimDiff and the MathWorks tool beside the git direct integration? Is there a Student Version? ThanksUndercut
SimDiff has been on the market since 2005, which I think is earlier than the Mathworks tool. Speed and accuracy has always been a point of emphasis for SimDiff. One significant advantage is that MATLAB doesn't need to be opened to perform a diff, which can save time and avoid using a MATLAB license.Verified
As far as a student license, I don't think we currently have one but students may instead be eligible for extended trial periods. But you should probably contact sales to confirm that; I'm not up to date on the latest policies.Verified
P
0

DiffPlug is a free git client with native support for Simulink. Diffing models isn't free, but you can view them from history for free.

Pacha answered 28/4, 2020 at 17:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.