MATLAB: How to configure a user-specific MATLAB path for a computer with multiple logins

MATLAB

I have a machine that multiple users log into and use the same MATLAB installation on. How can I configure a user-specific MATLAB path for a computer with multiple logins?

Best Answer

  • The PathTool modifies the first MATLAB "pathdef.m" file that it finds at startup for each user. The instructions below describe how to set up a "pathdef.m" file for each user so each user can manage their separate path on this shared machine.
    Users can specify the first-option for the MATLAB search path using the "userpath" command:
    >> userpath
    With that location, they can save their own version of the "pathdef.m" file which MATLAB will use first in their "userpath" directory.
    >> cd(userpath)
    >> savepath pathdef.m
    This way when they start MATLAB, MATLAB will add the "userpath" as the first place to search, then find the "pathdef.m" file when and load the user's path from there.
    After restarting MATLAB, users can now use the PathTool to modify their userpath and they will see the changes added to their "pathdef.m" file in their "userpath" location. Users can also add other paths to the MATLAB path temporarily using the "addpath" command
    If there are any issues from this, you can simply delete or rename the "pathdef.m" file in the "userpath" location and run:
    >> restoredefaultpath
    >> rehash toolboxcache
    >> savepath
    to return the MATLAB installation to the default search paths.