title: Matlab Attempt to execute script as a function
body: <p>I have a matlab script, lets call it "master.m", that loads a file called "config.m". config.m contains all the variables used in master.m so that they can be changed easily without editing any of the code. Problem is, I am trying to get the main function in master.m to load config.m based on the user input. So basically I want the user to be able to specify the name of the file to load. For instance if config.m was called testing.m then the user could type at the matlab prompt:</p>
  
  <pre><code>&gt;&gt; master(testing.m)
  </code></pre>
  
  <p>and it would load up the file. BUT I can't figure out how to do this properly, I have looked into the <code>eval</code> function but it gives me an error. Here is the code I have as of now in master.m:</p>
  
  <pre><code>function [X,Y] = master(file)
  eval(file)
  </code></pre>
  
  <p>However when I run at the matlab prompt:</p>
  
  <pre><code>&gt;&gt; master(config.m)  
  ??? Attempt to execute SCRIPT config as a function:
  /home/myusername/config.m
  </code></pre>
  
  <p>I have also tried <code>master('config.m')</code>,
  <code>master('./config.m')</code>, <code>master(config)</code> and <code>master(config.m)</code> but to no avail</p>
  
  <p>Any ideas?</p>