Using MATLAB comparison as an external diff tool

30 views (last 30 days)
I am using Git and SourceTree for source control. How can I use MATLAB comparison tool as an external diff tool there? How should I change the .gitconfig or set the required command in SourceTree diff option?

Answers (3)

Steven Lord
Steven Lord on 4 Jan 2017
As of release R2016b you can use the instruction on this page in the documentation to configure an external source control tool to use the MATLAB Comparison Tool to diff and merge code.
  5 Comments
David Barry
David Barry on 18 Sep 2018
@TS I am having the exact same problem as you but swapping to %LOCAL %REMOTE doesn't seem to solve it for me. I have attached a screenshot showing my config options from SourceTree. Can you please just confirm this is exactly what you entered to fix the issue?
Regards David
David Barry
David Barry on 18 Sep 2018
In case anybody else is having this issue, the solution is to set the arguments to $LOCAL $PWD/$REMOTE

Sign in to comment.


Jan
Jan on 4 Jan 2017
You can call the built-in comparison tool, buit it is not documented and will be subject to changes. What is the desired output?
In Matlab R2016b:
file1 = which('plot.m')
file2 = which('diff.m')
html = comparisons_private('textdiff', file1, file2);
web(['text://', html])
Look into the source of comparisons_private.m to see more options.
You can find out these methods by starting the profiler and select the "Compare" menu in the editor. Afterwards profile report tells you, which functions are called. As far as I can see, this is not a reverse engineering of Matlab and therefore it is legal.

Rebecca Nakhoul
Rebecca Nakhoul on 12 May 2020
To customize source control tools to use MATLAB for Diff and Merge, follow the steps described in the MATLAB documentation.
It covers source control tools such as SourceTree Git, Tortoise SVN and Perforce P4V.

Categories

Find more on Source Control Integration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!