Main Content


Search path separator for current platform



c = pathsep returns the search path separator character for the current platform. The search path separator is the character that separates path names in the pathdef.m file, as returned by the path function. On Windows®, the character is a semicolon (;). On UNIX® the character is a colon (:). Use pathsep to work programmatically with the content of the search path file.


collapse all

Use genpath in conjunction with regexp and pathsep to get a list of individual folders within a path name.

Create a folder myfolder containing a subfolder mysubfolder.

mkdir myfolder;
cd myfolder;
mkdir mysubfolder;
cd ..

Generate a path name that includes myfolder and all folders below it.

p = genpath('myfolder')
p = 

Use the regexp function to split the path into individual folders.

s = regexp(p, pathsep, 'split')
s = 1x3 cell
    {'myfolder'}    {'myfolder/mysubfolder'}    {0x0 char}

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced before R2006a