title: Array of structures in MATLAB Simulink
body: <p>I am trying to create an array of structures in Simulink and got some problems with it.
  first of all i tried to create it directly in Simulink using this:</p>
  
  <pre><code>function a = fcn(Dibhole, t , x, const)
  %#codegen
  %Output = zeros(10,10);
  f1 = 'number';
  f2 = 'move';
  cube = struct(f1, 0, f2, 0);
  a = repmat(cube, 20, 10);
  for i = 1:20
      for j = 1:10
          a(i,j).number = 0;
          a(i,j).move   = 0;
      end
  end
  </code></pre>
  
  <p>and i got this error:</p>
  
  <p>Derived output was of type struct. 'Inherited type' is unsupported for this
  type and a defined bus object must be used instead. Click on 'a' and
  set data type for 'a' to be 'Bus: ', where '' is
  the name of a bus object from the MATLAB workspace.</p>
  
  <p>So i found some example how to create struct in Matlab and receive this to Simulink: <a href="http://blogs.mathworks.com/seth/2011/12/05/initializing-buses-using-a-matlab-structure/" rel="nofollow">http://blogs.mathworks.com/seth/2011/12/05/initializing-buses-using-a-matlab-structure/</a>
  That works perfectly but i still can't repeat this with array:</p>
  
  <pre><code>f1 = 'number';
  f2 = 'move';
  cube = struct(f1, 0, f2, 0);
  myStruct2 = repmat(cube, 20, 10);
  for i = 1:20
      for j = 1:10
          myStruct2(i,j).number = 1;
          myStruct2(i,j).move   = 1;
      end
  end
  
  busInfo = Simulink.Bus.createObject(myStruct2);
  </code></pre>
  
  <p>Can anyone clarify to me what's the problem? Or maybe there is different way to create array of struct in Simulink?</p>
  
  <p>Mihail</p>