userpath - View or change default user work folder - MATLAB (original) (raw)

Main Content

View or change default user work folder

Syntax

Description

userpath([newpath](#btn2ix6-1-newpath)) sets the user-specific folder on the search path to 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.

example

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:

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.

example

Examples

collapse all

This example assumes the userpath folder is set to the default value Documents\MATLAB on the Windows platform. Start MATLAB and display the current folder.

In this example, H is the drive in whichDocuments is located.

Confirm that the current folder is the_userpath_ folder.

Display the search path. MATLAB returns the search path, including the folder specified byuserpath.

MATLABPATH

H:\Documents\MATLAB
C:\Program Files\MATLAB\R2009a\toolbox\matlab\general
C:\Program Files\MATLAB\R2009a\toolbox\matlab\ops

...

Assume the userpath folder is set to the default value on the Windows platform, Documents\MATLAB.

Change the value from the default toC:\Research_Project.

newpath = "C:\Research_Project"; userpath(newpath)

View the effect of the change by displaying the search path.

MATLABPATH

C:\Research_Project
C:\Program Files\MATLAB\R2009a\toolbox\matlab\general
C:\Program Files\MATLAB\R2009a\toolbox\matlab\ops

...

MATLAB displays the search path, including the folder specified byuserpath. MATLAB automatically removes the previous value of the_userpath_ folder,H:\Documents\MATLAB, from the search path when you assign a new folder using userpath.

Assume that the userpath folder is set to the default value, but you do not want it to be added to the search path at startup.

Confirm that the default is set.

Verify that it is on the search path.

MATLABPATH

H:\Documents\MATLAB C:\Program Files\MATLAB\R2009a\toolbox\matlab\general C:\Program Files\MATLAB\R2009a\toolbox\matlab\ops ...

Clear the value.

Verify the result.

Confirm that the former userpath folder is removed from the search path.

MATLABPATH

C:\Program Files\MATLAB\R2009a\toolbox\matlab\general C:\Program Files\MATLAB\R2009a\toolbox\matlab\ops ...

Note

If you use userpath("clear"), the startup folder will not necessarily be on the search path. This situation can also occur if you remove the userpath folder from the search path and save the changes.

Input Arguments

collapse all

New value for the userpath folder, specified as a string scalar or character vector. newpath must be an absolute path.

Example: "C:\myFolder"

Limitations

Tips

Version History

Introduced in R2008a