title: Get name of file in a folder containing a specific string (faster) in MATLAB
body: <p>I have a folder where the post processed files from a numerical model are stored with different names. for e.g. - WL.{simulation_name}.nc, UVel.{simulation_name}.nc, etc.</p>
  
  <p>I am writing a generalized script in MATLAB to pick out the files that I need and process it further, irrespective of the simulation name :</p>
  
  <pre><code>dirFiles = dir(pwd)
  
  for ii = 3:size(dirFiles,1)
      s = dirFiles(ii).name
      if strfind(s,'WL')
         Data.WL = nc_varget(dirFiles(ii).name,'WL');
      end
  end
  </code></pre>
  
  <p>The problem is the folder usually contains more than 30-40 files with different variables. And the loops in the above script are immensely slowing down the processing time.</p>
  
  <p>Is there any way to have a cleaner and faster solution?</p>
  
  <p>P.S: One way would be to use eval function, But I really don't want to use it unless it is the last option.</p>
  
  <p>Thanks!!
  Cheers.</p>