title: Get object handle given the name as a string (MATLAB)
body: <p>Being given the name of a variable as a string (in my case the name of an existing Simulink.Parameter variable in the workspace selected by the user as a design variable for optimization), I would like to be able to access the properties of the object such as Simulink.Parameter.Min, Simulink.Parameter.Max, Simulink.Parameter.Value <strong>without using eval()</strong>. So far I am employing the (very ugly) solution</p>
  
  <pre><code>varnames = {'var1','var2'}; % Simulink.Parameter objects existing in workspace
  objects = cell(length(varnames),1);
  for i = 1:length(varnames)
      eval(['objects{i}=', varnames{i}, ';']) % Store objects in a cell array
  end
  </code></pre>
  
  <p>Ideally, this would look like:</p>
  
  <pre><code>objects = get_object_handles_from_string(varnames);
  value_1 = object{1}.Value(:);
  </code></pre>
  
  <p><em>Otherwise a method returning the variable name given the object handle would also be acceptable.</em> </p>
  
  <p>Methods that I found not to be working but might be useful otherwise:</p>
  
  <ul>
  <li><a href="https://de.mathworks.com/help/matlab/ref/whos.html" rel="nofollow noreferrer">whos</a> finds variable names and properties in the current workspace but no handles.</li>
  <li><a href="https://de.mathworks.com/help/matlab/ref/inputname.html" rel="nofollow noreferrer">inputname</a> returns the variable name of an explicit function input as a string but does not work for cell arrays of objects (see this <a href="https://stackoverflow.com/a/11453337/8751939">question</a>).</li>
  <li><a href="https://de.mathworks.com/help/matlab/ref/str2func.html" rel="nofollow noreferrer">str2func</a> returns a function handle with a string as input but does not enable access to attributes. </li>
  <li><a href="https://de.mathworks.com/help/matlab/ref/handle.findobj.html" rel="nofollow noreferrer">findobj</a> returns objects given an array of objects to iterate over which I do not have. Might there be a method returning all workspace variable handles as an array?</li>
  </ul>
  
  <p>Thanks!</p>