Today I came across this topic:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/112560
The question is how to get Matlab to read the startup.m file no matter where you start the Matlab session.
One of the proposed solutions:
One solution would be to ask the system administrator to add a few lines to "matlabrc.m", which adds some predefined folder in the home user directory to the MATLAB path (say ~ / .matlabstart). Then each user can have their own file "startup.m" inside this folder.
What I ended up on my system (OS X) was to add the startup.m file to:
/Applications/MATLAB_R2011a.app/toolbox/local/
In this startup.m file, I added:
if exist([getenv('HOME') '/.matlabrc/startup.m']) run([getenv('HOME') '/.matlabrc/startup.m']); end
Thus, users have the opportunity to create a hidden folder ~/.matlabrc , and inside it they can put the file startup.m . In this startup file, they can tell matlab what to do when they start Matlab, regardless of the directory in which they started it. An example of what I added to my own startup.m file,
addpath(genpath('/Users/jmlopez/matlabcode/'))
Now I can add as many folders inside this directory, and all of them will be added to the path every time I start Matlab automatically, without changing the path.
The question is, did Matlab provide a special file similar to the one I created, or did I just go through all these problems to accomplish what I wanted? If the answer is the second option I gave, then why doesn't Matlab provide this? Itβs a pain in the ass to add directories to the Matlab path whenever you do not have administrator privileges, and I donβt want to transfer my startup.m file to every directory I go to. Can someone shed some light on this, please?