Reputation: 1002
Suppose two different Matlab users share a computer and they each want to be able to save and load their own Matlab paths. (Or, a single user wants to use different paths at different times.) What's the easiest way to handle this?
Should there be multiple pathdef files? Alternatively, should they each have a script that calls restoredefaultpath and then uses addpath to add new paths?
Upvotes: 3
Views: 772
Reputation: 112749
You can use the startup.m
file for that.
When starting up, Matlab executes the file matlabrc.m
, which is the master startup file, and is common for all users. Among other things, this file
pathdef
, which in turn calls userpath
); and thenstartup.m
file in the path, end executes if it exists.Therefore you can place a user-specific startup.m
file in each user's folder, and Matlab will run the appropriate file depending on which user started Matlab. In that file you can set the path on a per-user basis, and do other user-related stuff.
Upvotes: 4