title: Iterate through a MATLAB structure numerically
body: <p>Is it possible to iterate through a MATLAB structure numerically like a vector instead of using the field names?</p>
  
  <p>Simply, I am trying to do the following inside an EML block for Simulink:</p>
  
  <pre><code>S.a.type = 1;
  S.a.val = 100;
  S.a.somevar = 123;    
  S.b.type = 2;
  S.b.val = 200;
  S.b.somevar2 = 234;
  S.c.type = 3;
  S.c.val = 300;
  S.c.somevar3 = 345;
  
  for i = 1:length(s)
      itemType = S(i).type;
      switch itemType
          case 1
              val = S(i).val * S(i).somevar1;
          case 2
              val = S(i).val * S(i).somevar2;
          case 3
              val = S(i).val * S(i).somevar3;
          otherwise
              val = 0
      end
  end
  
  disp(var);
  </code></pre>