title: MatLab load file from relative path
body: <p>I have file <code>my_file.m</code> in the directory <code>C:\...\mydir\</code>, does not matter which. I have data I wish to load <code>C:\...\mydir\anotherdir\</code> which contains my files I wish to load. The following does not seem to work.</p>
  
  <pre><code>files = dir('anotherdir\*.mat');
  </code></pre>
  
  <p>I want to load files which are relative to the <code>my_file.m</code> which is requesting them.</p>
  
  <p>Answer: To load it further use the following:</p>
  
  <pre><code>current_dir = pwd;
  files = dir([current_dir '\anotherdir\*.mat']);
  dname=[current_dir '\anotherdir\'];
  
  for i=1:length(files)
      fname=fullfile(dname,files(i).name);
      A = load(fname);
  end
  </code></pre>