title: Create multiple substructs in loop and indexing with cellarray
body: <p>Let's say I have got a struct called data and I want to create three substructs called area, inhabitants and industry. These names are stored in a cellarray.
  My method looks like this:</p>
  
  <pre><code>names={'area','inhabitants','industrie'};
  for i=1:length(names)
  data.(names(i)) = struct;
  end
  </code></pre>
  
  <p>I get this error: "Argument to dynamic structure reference must evaluate to a valid field name."</p>
  
  <p>However doing it like this works:</p>
  
  <pre><code>somestr = 'area';
  data.(somestr) = struct;
  </code></pre>
  
  <p>That's why I tried:</p>
  
  <pre><code>names={'area','inhabitants','industrie'};
  for i=1:length(names)
      somestr = names(i);
      data.(somestr) = struct;
  end
  </code></pre>
  
  <p>But I get the same error as before.
  I want to do it that way because I have to import a lot of data and want to store it in Matlab. If someone later wants to change the code it might be much easier to just change the cellarray.</p>