Skip to Main Content Skip to Search
Product Documentation

genpath - Generate path string

Syntax

genpath
genpath folderName
p = genpath('folderName')

Description

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

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

p = genpath('folderName') returns the path string to variable, p.

Examples

Generate a path that includes matlabroot/toolbox/images and all folders below it:

p = genpath(fullfile(matlabroot,'toolbox','images'))

p =

C:\Program Files\MATLAB\R20nn\toolbox\images;C:\Program Files\MATLAB\
R20nn\toolbox\images\images;C:\Program Files\MATLAB\R200nn\toolbox\
images\images\ja;C:\Program Files\MATLAB\R200nn\toolbox\images\
imdemos;C:\Program Files\MATLAB\R200nn\toolbox\images\imdemos\ja;

R200nn represents the folder for the MATLAB release, for example, R2009b.

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

addpath(genpath('c:/matlab/myfiles'))

See Also

addpath | path | pathsep | pathtool | rehash | restoredefaultpath | rmpath | savepath

How To

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS