title: Iterate through a structure in MATLAB without 'fieldnames'
body: <p>The usual way to iterate through a struct data type in MATLAB is using the <code>fieldnames()</code> function as done in:</p>
  
  <pre><code>mystruct = struct('a',3,'b',5,'c',9);
  
  fields = fieldnames(mystruct);
  
  for i=1:numel(fields)
    mystruct.(fields{i});
  end
  </code></pre>
  
  <p>Unfortunately, this always generates cell data types, and I would like to use this kind of iteration for a Matlab Function Block in SIMULINK that does not allow cell data types for code generation reasons.</p>
  
  <p><strong>Is there a way to iterate through a structure without making use of cell data types at the same time?</strong></p>
  
  <p>In Octave there is a neat way of that explained in <a href="https://www.gnu.org/software/octave/doc/interpreter/Looping-Over-Structure-Elements.html">https://www.gnu.org/software/octave/doc/interpreter/Looping-Over-Structure-Elements.html</a></p>
  
  <pre><code>for [val, key] = mystruct
    # do something esp. with 'key'
  end
  </code></pre>
  
  <p>Does anybody know a similar way in MATLAB?</p>