title: Read images from subdirectories
body: <p>I have a directory that contains several folders. Each of these folders contains several images.</p>
  
  <p>If we suppose that we have a directory that contains images, I know how to read these images (see my code below); If we suppose that these images are placed in subdirectories in this directory, then I don't know how to edit my code.</p>
  
  <pre><code>directory = 'my_direct';
  dnames1={directory};
  c{1} = dir(dnames1{1}); % struct array with 5 fileds (name, isdir,...)
  
  if length(c{1}&gt;0)
      if c{1}(1).name =='.'
          c{1} = c{1}(3:end); %ignore the '.' and '..'
      end
  end
  
  for k = 1: length(c{1})
      image= double(imread([dnames{1} '/' h{1}(L).name]))./255;
  end
  </code></pre>