| MATLAB® | ![]() |
genpath
genpath directory
p = genpath('directory')
genpath returns a path string formed by recursively adding all the directories below matlabroot/toolbox.
genpath directory returns a path string formed by recursively adding all the directories below directory. This path string does not include directories named private or directories that begin with the @ character.
p = genpath('directory') returns the path string to variable, p.
To generate a path that includes matlabroot/toolbox/images and all directories below it, run the following:
p = genpath(fullfile(matlabroot,'toolbox','images'))
p =
matlabroot\toolbox\images;matlabroot\toolbox\images\ images;matlabroot\toolbox\images\images\ja; matlabroot\toolbox\images\imdemos;matlabroot\ toolbox\images\imdemos\ja;
You can also use genpath in conjunction with addpath to add subdirectories to the path. The following example adds the \control directory and its subdirectories to the current path.
% Display the current path
path
MATLABPATH
K:\toolbox\matlab\general
K:\toolbox\matlab\ops
K:\toolbox\matlab\lang
K:\toolbox\matlab\elmat
K:\toolbox\matlab\elfun
:
:
:
% Use GENPATH to add \control and its subdirectories
addpath(genpath('K:\toolbox\control'))
% Display the new path
path
MATLABPATH
K:\toolbox\control
K:\toolbox\control\ctrlutil
K:\toolbox\control\control
K:\toolbox\control\ctrlguis
K:\toolbox\control\ctrldemos
K:\toolbox\matlab\general
K:\toolbox\matlab\ops
K:\toolbox\matlab\lang
K:\toolbox\matlab\elmat
K:\toolbox\matlab\elfun
:
:
:addpath, path, pathsep, pathtool, rehash, restoredefaultpath, rmpath, savepath
Search Path in the MATLAB Desktop Tools and Development Environment documentation
![]() | ge | genvarname | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |