MATLAB: Are system users unable to create and modify their own pathdef.m files in MATLAB 7.7 (R2008b)

MATLAB

I am a system administrator. My users are not able to modify and save paths in MATLAB.

Best Answer

If users are not able to modify their paths, it is likely that they are reading the path from the administrator's write-protected 'pathdef.m' file.
You can create a 'pathdef.m' file for each user in the user's startup directory. The user startup directory is the working directory of MATLAB on a fresh startup, so the easiest way to resolve the issue is to have users type 'savepath pathdef.m' as the first command when they start MATLAB. They should then restart MATLAB, and the path will now be obtained from the newly created pathdef.m file. You can use the command 'which pathdef' to determine which 'pathdef.m' file is being used.
Another workaround is to add the following code to the MATLABRC file. The MATLABRC file is reserved for use by system administrators. You can find the location of this file by typing 'which matlabrc' at the MATLAB command prompt. If you add the following code, MATLAB will check whether a 'pathdef.m' file exists for the user on startup, and if it does not exist, one will be created specific to the user.
up = userpath;
up = regexprep(up,';',''); %Remove semicolon at end of userpath
if ~exist([up filesep 'pathdef.m'],'file')
savepath([up filesep 'pathdef.m'])
end