Generate path string
p = genpath returns a path string, p, that includes all the folders and subfolders below matlabroot/toolbox, including empty subfolders.
p = 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, folders that begin with the @ character (class folders), folders that begin with the + character (package folders), or subfolders within any of these.
Use genpath in conjunction with addpath to add a folder and its subfolders to the search path.
Generate a path that includes matlabroot/toolbox/images/colorspaces and all folders below it.
folderName = fullfile(matlabroot,'toolbox','images','colorspaces'); p = genpath(folderName);
Add the folder and its subfolders to the search path.