| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
genpath
genpath folderName
p = genpath('folderName')
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.
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'))
addpath, path, pathsep, pathtool, rehash, restoredefaultpath, rmpath, savepath
![]() | ge | genvarname | ![]() |

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 |