This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Search path separator for current platform


c = pathsep



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 array
    {'myfolder'}    {'myfolder/mysubf...'}    {0x0 char}

Introduced before R2006a