MATLAB Function Reference
  Go to function:
    Search    Help Desk 
path    Examples   See Also

Control MATLAB's directory search path

Syntax

Description

path prints out the current setting of MATLAB's search path. The path resides in pathdef.m (in toolbox/local).

p = path returns the current search path in string variable p.

path('newpath') changes the path to the string 'newpath'.

path(path,'newpath') appends a new directory to the current path.

path('newpath',path) prepends a new directory to the current path.

Remarks

MATLAB has a search path. If you enter a name, such as fox, the MATLAB interpreter:

   1.
Looks for fox as a variable.
   2.
Checks for fox as a built-in function.
   3.
Looks in the current directory for fox.mex and fox.m.
   4.
Searches the directories specified by path for fox.mex and fox.m.
Note
Save any M-files you create or any MATLAB-supplied M-files that you edit in a directory that is not in the MATLAB directory tree. If you keep your files in the MATLAB directory tree, they might be overwritten when you install a new version of MATLAB. Another consideration is that files in the MATLAB/toolbox directory tree are loaded and cached into memory at the beginning of each MATLAB session to improve performance. This cache is not updated until MATLAB is restarted. If you add any files or make changes to any files in the toolbox directory, you will not be able to see the changes until you restart MATLAB.

Examples

Add a new directory to the search path on various operating systems

UNIX

path(path,'/home/myfriend/goodstuff')
VMS

path(path,'DISKS1:[MYFRIEND.GOODSTUFF]')
Windows

path(path,'TOOLS\GOODSTUFF')
.

See Also

addpath, cd, dir, partialpath, rmpath, what



[ Previous | Help Desk | Next ]