genpath
Returns a path string listing a folder and all of its subfolders.
Category: Programming > Files and Folders
Syntax
p = genpath(folder)
Builds the path string for folder and every folder below it.
Description
genpath only builds a string; it does not change the search path. Pass the result to addpath to put a whole tree on the path at once: addpath(genpath('lib')).
The listing leaves out folders that MATLAB treats as special, namely those whose names start with @ (class folders), + (package folders) or private, and folders called resources.
Input arguments
folder- Root folder, as text.
Output arguments
p- Folders separated by
pathsep, root first, each followed by its subfolders.
Example
Folders of a small tree
mkdir lib/inner
mkdir lib/more
p = genpath('lib')
Output
p = 'lib;lib\inner;lib\more;'
Notes
The returned text keeps relative folders relative and ends with a separator.