title: dynamic structure generation in Matlab
body: <p>I have a list of field names and want to generate a nested struct. I tried this:</p>
  
  <pre><code>fn1 = {'a', 'b', 'c'};
  fn2 = {'d', 'e', 'f'};
  s = struct();
  for n1=fn1
    for n2=fn2
      s.(n1).(n2) = 0 ;
    end
  end
  </code></pre>
  
  <p>but Matlab complaint that the notation ".{fieldname)" is for dynamic structure reference only ("Argument to dynamic structure reference must evaluate to a valid field name.").</p>
  
  <p>I know a solution that works is to loop over the field names, using isfield() and struct().
  So how can I achieve this goal without using isfield() and struct(), e.g. by mean of some anonymous function and vectorization? Thanks</p>