next up previous contents
Next: Numerical Formats Up: M-files Previous: Function Files

Paths

 

MATLAB cannot search the entire filesystem for m-files. The places MATLAB looks, and the order in which it searches them, are defined by the path. The command path will list them from first to last as a vector of strings. On Athena, the initial path will consist of a set of directories in the matlab locker, and your tex2html_wrap_inline2377 /matlab directory if it exists; the directory where you run MATLAB does not get put in the path, but the current directory always gets searched for m-files.

Giving path an argument of one or more strings will set the path to that list. Usually one merely wants to extend the current path and therefore does path(path, '/mit/foo') or path('/mit/foo', path) to retain the current path but add /mit/foo to its end or beginning, respectively. The function addpath('new path') simplifies this operation; the function rmpath simplifies the reverse. These are both in the contrib/names toolbox, which is primarily for name collision testing; see help contrib/names or just help names.

To see the source of a given function or m-file, which gives the path followed to find its argument, while where gives all paths with a file matching the argument. If you are seeking a function to do some job, but whose name you do not know, use lookfor to search for a keyword.

When MATLAB wants to know what you mean by a name, it first looks for a variable of that name, then for a built-in function, then for an m-file in the current directory, and finally for an m-file in the path. Use clash to see what m-files will collide with a particular name.



sepherke
Sat Mar 21 21:42:28 EST 1998