# path

## Purpose

Control MATLAB's directory search path.

## Synopsis

    path
    p = path
    path(p)
    path(p1,p2)

## Description

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`.

`path`, by itself, prints out the current setting of MATLAB's search path. The search path list originates from the environment variable `MATLABPATH` in the underlying operating system, which is set in MATLAB's startup script, or is set by`matlabrc.m`, and is perhaps individualized by `startup.m`.

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

`path(p)` changes the path to the string in `p`.

`path(p1,p2)` changes the path to the concatenation of the two path strings `p1` and `p2`. Thus `path(path,p)` appends a new directory to the current path and `path(p,path)` prepends a new path.

## 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

    cd, dir, getenv, what

(c) Copyright 1994 by The MathWorks, Inc.