title: Why is MATLAB sensitive to order of fields in a struct array assignment?
body: <p>First I specify <code>A</code> as a struct, and two other structs: <code>B</code> having the same order of elements, and <code>C</code> having a different order of elements.</p>
  
  <pre><code>A.x = 11;
  A.y = 11;
  
  B.x = 21;
  B.y = 22;
  
  C.y = 31;   %// Note that I am specifying
  C.x = 32;   %// y first and x second
  
  A = B;      %// Works fine
  A = C;      %// Works fine
  </code></pre>
  
  <p>Assigning <code>A</code> to <code>B</code> and to <code>C</code> works, which is the behavior I expect from structs - order of elements should not matter.</p>
  
  <p>Now I specify <code>A</code> as a struct array instead of a struct and try to assign one of its elements to <code>B</code> and <code>C</code> respectively:</p>
  
  <pre><code>clear;
  
  A(1).x = 11;
  A(1).y = 12;
  
  B.x = 21;
  B.y = 22;
  
  C.y = 31;   %// Note that I am specifying
  C.x = 32;   %// y first and x second
  
  A(1) = B;   %// Works fine
  A(1) = C;   %// Error!
  </code></pre>
  
  <p>Suddenly MATLAB is complaining with the error:</p>
  
  <blockquote>
    <p>subscripted assignment between dissimilar structures</p>
  </blockquote>
  
  <p>Does anyone have any idea why this happens and how to fix it in an elegant way?</p>