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\MATLAB
Mac platforms —
$home/Documents/MATLAB
Linux® platforms —
$home/Documents/MATLAB
if$home/Documents
exists
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
userpath
folder. Changing the folder is not supported.
Tips
To specify the startup folder, set the Initial working folder preference, located in the General Preferences page of the Preferences window. For more information about using
userpath
as the initial working folder, see userpath as Initial Working Folder.The
MATLABPATH
environment variable can contain a list of folders to be added to the search path. MATLAB adds the folders specified in theMATLABPATH
environment variable to the search path below theuserpath
folder at startup.
Version History
Introduced in R2008a