You can do it like this:
basePath = pwd; %your base path which is in your case myTraining
allPaths = dir(basePath); %get all directory content
subFolders = [allPaths(:).isdir]; %get only indices of folders
foldersNames = {allPaths(subFolders).name}'; % filter folders names
foldersNames(ismember(foldersNames,{'.','..'})) = []; %delete default paths for parents return '.','..'
for i=1:length(foldersNames), %loop through all folders
tmp = foldersNames{i}; %get folder by index
p = strcat([basePath '\']);
currentPath =strcat([p tmp]); % add base to current folder
cd(currentPath); % change directory to new path
files = dir('*.jpg'); % list all images in your path which in your case could be John or Mary
for j=1:length(files), % loop through your images
img = imread(files(j).name); % read each image and do what you want
end
end