3

Which files or folders of MATLAB installations should be under revision control?

I don't mean my code, models etc but MATLABs configuration files, application data and so on. Everything that's needed to ensure that all my team have the same setup.

Craig
  • 991
  • 1
  • 13
  • 28
  • That depends on your setup, doesn't it? The answer will be different if you want equal editor settings etc. or if you want `startup.m` to be the same...It depends on what aspects you want to be equal (I'm restraining myself from asking *why* you'd want to do this...) – Rody Oldenhuis Jan 17 '13 at 10:56
  • For example: I want confidence that fresh installs for new users will have all the fiddly settings already done for them, or that I could deploy new virtual machines that will build a binary identical executable as from my own workstation or a colleagues. – Craig Jan 17 '13 at 12:26
  • Following article has some info where the preferences can be found: http://blogs.mathworks.com/community/2010/05/31/command-line-preferences/ - from what you are asking I wonder why you would use version control for such a deployment. – bdecaf Jan 17 '13 at 13:47
  • @bdecaf thanks for that link. Those preference commands seem to relate to GUI development and have user-specific values. I agree that those preferences are not of interest for version control, however, general Matlab and Simulink settings are (for me). For instance new users could do hours of work only to find that their work has to be repeated because they haven't used the right solver (we always use the same one). Also an incorrect compiler setting could cost hours of investigations. Both these problems could be overcome if the relevant config file was controlled using a VCS. – Craig Jan 17 '13 at 14:20
  • Also see http://stackoverflow.com/a/1880876/643210 – Craig Jan 17 '13 at 15:40
  • @Craig - From what I understand you don't want your users to fiddle with the preferences you provide, therefore I wonder why you would need a VCS to track changes. Keep in mind you would also need to train them how to merge updates into their files later on. – bdecaf Jan 18 '13 at 10:59

1 Answers1

1

The best way to manage this is through the use of an initialization script. Put this in the top level project folder, and name it something nice:

%% initMyProject.m

% RestoreDefault
restoredefaultpath();
set(0,'userdata',[]);
clear classes;
javaclasspath({});  

% Matlab
addpath(fullfile(pwd,'lib','subdirA'))
addpath(fullfile(pwd,'lib','subdirB')) % ..etc

% Java
addpath(fullfile(pwd,'java','myJarA.jar') 
addpath(fullfile(pwd,'java','myJarB.jar') % ..etc

% Rendering
opengl('hardware');

% Solver
setparam(...)

disp('Initialization complete.')

The user would then edit a startup.m (as described here), to call the init script. This file should be placed in the Linux user's home directory, or the C:/Users//Documents/Matlab directory (Windows):

% startup.m
cd('C:\workspace\myProjectCheckout')
initMyProject()

This approach has a number of benefits:

  • Settings remain synchronized when you do an svn update or git pull
  • Scales nicely to multiple projects, multiple checkouts
  • Admin privileges not required, no user-copying of files
  • Compatible across Linux, Mac, and PC, and across Matlab Versions (much more stable than trying to directly manage config settings files)

The restoreDefault methods are a bit heavy-handed, but they do guarantee a clean environment, so use as necessary.

supyo
  • 3,017
  • 2
  • 20
  • 35
  • thanks for the answer. I had not realised that 'clear all' didn't clear some things! Sorry I can't accept though as some things are still left uncontrolled. e.g. the compiler settings used by 'mex' are stored (Windows 7 default) at '%USERPROFILE%\AppData\Roaming\MathWorks\MATLAB\\mexopts.bat' and are effective regardless of 'path'. – Craig Mar 15 '13 at 11:31