MATLAB Functions Help Desk

path

Purpose

Control MATLAB's directory search path

Syntax

Description

path prints out the current setting of MATLAB's search path. On all platforms except the Macintosh, the path resides in pathdef.m (in toolbox/local). The Macintosh stores its path in the Matlab Settings File (usually in the
Preferences folder).

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.

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]')

MS-DOS:

path(path,'TOOLS\GOODSTUFF')

Macintosh:

path(path,'Tools:GoodStuff')

See Also

addpath     Add directories to MATLAB's search path

cd          Change working directory

dir         Directory listing

rmpath      Remove directories from MATLAB's search path

what        Directory listing of M-files, MAT-files, and MEX-files



[ Previous | Help Desk | Next ]