%% Get List of Subfolders Within Path Name
% Use genpath in conjunction with regexp and pathsep to get a list of individual folders within a path name.
% Create a folder myfolder containing a subfolder mysubfolder.

mkdir myfolder;
cd myfolder;
mkdir mysubfolder;
cd ..

%
% Generate a path name that includes myfolder and all folders below it.

p = genpath('myfolder')

%
% Use the regexp function to split the path into individual folders.

s = regexp(p, pathsep, 'split')

% Copyright 2012 The MathWorks, Inc.