How can I configure a user-specific MATLAB path on a shared computer?
32 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 5 Jun. 2020
Bearbeitet: MathWorks Support Team
am 8 Jul. 2025
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?
Akzeptierte Antwort
MathWorks Support Team
am 8 Jul. 2025
Bearbeitet: MathWorks Support Team
am 8 Jul. 2025
The MATLAB search path is initialized at startup from a configuration file called pathdef.m. The system-wide pathdef.m file is located in the MATLAB installation path, which on Windows typically is:
C:\Program Files\MATLAB\RXXXXx\toolbox\local\pathdef.m
The following options describe several ways to manage customized, user-specific paths:
If it can be ensured that the system pathdef.m file is protected from modification by users, the recommended approach is to add custom paths at startup. This allows each user to layer their own folders on top of the default, version-specific MATLAB search path without affecting other users.
To automate this, users can create a personal startup.m file containing 'addpath' commands in their MATLAB userpath folder (usually C:\Users\username\Documents\MATLAB). Alternatively, utilize a user-specific environment variable. For more information, see: Add Folders to the MATLAB Search Path at Startup.
A great option for collaborative environments is to add folders to the MATLAB path on a project basis. Learn more about project paths here: MATLAB Projects and Simulink Projects.
Each user can maintain a personal pathdef.m in their MATLAB user folder. This method gives each user full control over their MATLAB search path.
NOTE: Do not use this option if multiple MATLAB versions are used. Upgrading MATLAB will require pathdef.m to be updated for each user.
Follow the steps below to configure personal MATLAB paths for each user on a shared computer:
1. Start MATLAB under the user account you wish to configure.
2. Confirm that the current pathdef.m file is in the MATLAB installation folder:
>> which -all pathdef
C:\Program Files\MATLAB\RXXXXx\toolbox\local\pathdef.m
3. Provided that you have write access to C:\Program Files\MATLAB\RXXXXx\toolbox\local\, if you want to start with a clean path, reset the MATLAB path to factory defaults by running:
>> restoredefaultpath
>> rehash toolboxcache
>> savepath
4. To determine the current userpath folder, call userpath:
>> userpath
The typical userpath location on Windows is C:\Users\username\Documents\MATLAB. For more information, see: userpath Folder on the Search Path.
5. Change to your userpath folder and save your own pathdef.m file using the savepath command:
>> cd(userpath)
>> savepath pathdef.m
6. Verify that the new pathdef.m in the userpath comes first on the search path:
>> which pathdef.m -all
C:\Users\username\Documents\MATLAB\pathdef.m
C:\Program Files\MATLAB\RXXXXx\toolbox\local\pathdef.m
7. Now the user can use the Current Folder Browser, the "Set Path" dialog, or the addpath command to customize your MATLAB, and save the changes to your personal pathdef.m file. See: Change Folders on Search Path.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!