Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

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 mymfiles and its subfolders to the search path:

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

See Also

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

Using the Search Path

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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