userpath
View or change default user work folder
Description
userpath returns a user-specific folder that MATLAB® adds to the search path at startup. The function returns the folder as
a character vector. For more information about the search path, see What Is the MATLAB Search Path?
For additional information on configuring MATLAB startup options, see Startup Options in MATLAB Startup File.
userpath( sets the user-specific
folder on the search path to newpath)newpath. The specified folder
appears on the search path immediately and at startup in future sessions.
MATLAB removes the folder previously specified by userpath
from the search path.
userpath("reset") sets the user-specific folder on the search
path to the default for your platform. The default
userpath folder depends on your platform:
Windows® platforms —
%USERPROFILE%\Documents\MATLABMac platforms —
$home/Documents/MATLABLinux® platforms —
$HOME/Documents/MATLABif$HOME/Documentsexists. If$HOME/Documentsdoes not exist, the function returns[]and no valid path is set.
MATLAB immediately adds the default folder to the search path and also adds it to the search path at startup in future sessions. On Windows and Mac platforms, the default folder is created if it does not exist. On Linux, the default folder is not created if it does not exist.
userpath("clear") removes the user-specific folder from the
search path immediately and for future MATLAB sessions.
Examples
Input Arguments
Limitations
In MATLAB Online™, you can only view the
userpathfolder. Changing the folder is not supported.
Tips
To specify the startup folder, set the Initial working folder setting, located in the General Settings page of the Settings Window. For more information about using
userpathas the initial working folder, see userpath as Initial Working Folder.The
MATLABPATHenvironment variable can contain a list of folders to be added to the search path. MATLAB adds the folders specified in theMATLABPATHenvironment variable to the search path below theuserpathfolder at startup.
Version History
Introduced in R2008a