This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Generate path name


  • p = genpath
  • p = genpath(folderName)


p = genpath returns a path name, p, that includes all the folders and subfolders below matlabroot/toolbox, including empty subfolders.


p = genpath(folderName) returns a path name that includes folderName and multiple levels of subfolders below folderName. The path name does not include folders named private, folders that begin with the @ character (class folders), folders that begin with the + character (package folders), or subfolders within any of these.


collapse all

Use genpath in conjunction with addpath to add a folder and its subfolders to the search path.

Create a folder myfolder containing a subfolder mysubfolder.

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

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

p = genpath('myfolder')
p =


Add the folder and its subfolders to the search path.


Input Arguments

collapse all

Folder name, specified as a character vector.

Example: 'c:/matlab/myfiles'

See Also

| |

Introduced before R2006a

Was this topic helpful?