Quantcast

Documentation Center

  • Trial Software
  • Product Updates

userpath

View or change user portion of search path

Syntax

Description

example

userpath returns a string specifying the first folder on the search path. MATLAB® adds the userpath to the search path upon startup.

example

userpath(newpath) sets the primary userpath folder to newpath. The newpath folder appears at the top of 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 primary userpath folder to the default for that platform, creating the Documents/MATLAB (or My Documents/MATLAB) folder, if it does not exist. MATLAB immediately adds the default folder to the top of the search path, and also adds it to the search path at startup in future sessions. On Linux, the MATLAB directory is not created if the Documents directory does not exist.

example

userpath('clear') clears the value for the primary userpath immediately, and for future MATLAB sessions. MATLAB removes the folder previously specified by userpath from the search path.

Examples

expand all

View userpath Folder

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

pwd
H:\My Documents\MATLAB

In this example, H is the drive at which My Documents is located.

Confirm that the current folder is the userpath.

userpath
H:\My Documents\MATLAB;

Display the search path.

path
MATLABPATH

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

MATLAB returns the search path. The userpath portion is at the top.

Set New Value for userpath

Assume userpath is set to the default value on the Windows XP platform, My Documents\MATLAB. Change the value from the default for userpath to C:\Research_Project.

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

View the effect of the change on the search path.

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, with the new value for userpath portion at the top. Note that MATLAB automatically removed the previous value of userpath, H:\My Documents\MATLAB, from the search path when you assigned a new value to userpath.

Clear the Value for userpath

Assume userpath is set to the default value and you do not want any folders to be added to the search path upon startup. Confirm the default is currently set.

userpath
H:\My Documents\MATLAB;

Verify that the userpath folder is at the top of the search path.

path
MATLABPATH

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

Clear the value.

userpath('clear')

Verify the result.

userpath
ans =
     ''

Confirm the userpath folder was removed from the search path.

path
MATLABPATH

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

    Note:   By default, the startup folder is the userpath folder when you start MATLAB by double-clicking the shortcut on Windows platforms, or by double-clicking the application on Macintosh platforms. If you clear the value for userpath, the startup folder will not necessarily be on the search path. Removing the userpath folder from the search path and saving the changes to the path has the same effect.

Input Arguments

expand all

newpath — New userpath valuestring

New userpath value, specified as a string. newpath must be an absolute path.

Example: 'C:\myFolder'

More About

expand all

Tips

  • On Macintosh and UNIX® platforms, you can automatically add subfolders to the top of the search path upon startup by specifying the path for the subfolders via the MATLABPATH environment variable.

See Also

| | | |

Was this topic helpful?