path
Shows or sets the search path.
Category: Programming > Files and Folders
Syntax
path
Displays the search path.
p = path
Returns the path as one character vector, folders separated by pathsep.
path(newpath)
Replaces the path with newpath.
path(path1, path2)
Joins two path strings and makes the result the path.
Description
The search path is the ordered list of folders where function files are looked up after the current folder. path reads or replaces it as a single string, whereas addpath and rmpath edit it one folder at a time and are usually the better tools.
Split the string with strsplit(path, pathsep) to work with the folders individually.
Input arguments
newpath- Folders separated by
pathsep. path1, path2- Two path strings; the call
path(path, 'dir')appendsdir, andpath('dir', path)prepends it.
Output arguments
p- The current path.
Example
Prepending a folder with path
mkdir tools
old = path;
path('tools', old);
parts = strsplit(path, pathsep);
parts{1}
path(old);
Output
ans = 'tools'