title: Dynamically name a struct variable in MATLAB
body: <p>I have several files "2011-01-01.txt", "2013-01-02.txt", "2015-02-01.txt", etc.
  I wish to create a struct variable for each of the file such that (the values are made up): </p>
  
  <pre><code>machine20110101.size=[1,2,3];
  machine20110101.weight=2345;
  machine20110101.price=3456;
  
  machine20130102.size=[2,3,4];
  machine20130102.weight=1357;
  machine20130102.price=123;
  
  machine20150201.size=[1,2,4];
  machine20150201.weight=1357;
  machine20150201.price=123;
  </code></pre>
  
  <p>And,</p>
  
  <pre><code>save('f20110101.mat','machine20110101');
  save('f20130102.mat','machine20130102') ;
  save('f20150201.mat','machine20150201');
  </code></pre>
  
  <p>As we can see, the struct names are derived from the files' names. How can I construct the above struct variables?</p>
  
  <p>I've searched for a while, but I didn't figure out how to use <code>genvarname</code>. </p>
  
  <p>And these links (<a href="https://stackoverflow.com/questions/29545862/dynamic-variable-names-in-matlab">dynamic variable names in matlab</a>, <a href="https://stackoverflow.com/questions/22586958/dynamic-variable-declaration-function-matlab">dynamic variable declaration function matlab</a>, <a href="https://stackoverflow.com/questions/26916160/dynamically-change-variable-name-inside-a-loop-in-matlab">Dynamically change variable name inside a loop in MATLAB</a>) didn't solve my problem.</p>
  
  <p>I'm using MATLAB R2012b, so functions like <code>matlab.lang.makeUniqueStrings</code> defined after this version is unavailable.</p>