title: What are some efficient ways to combine two structures in MATLAB?
body: <p>I want to combine two structures with differing fields names.</p>
  
  <p>For example, starting with:</p>
  
  <pre><code>A.field1 = 1;
  A.field2 = 'a';
  
  B.field3 = 2;
  B.field4 = 'b';
  </code></pre>
  
  <p>I would like to have:</p>
  
  <pre><code>C.field1 = 1;
  C.field2 = 'a';
  C.field3 = 2;
  C.field4 = 'b';
  </code></pre>
  
  <p>Is there a more efficient way than using "fieldnames" and a for loop?</p>
  
  <p><strong>EDIT:</strong> Let's assume that in the case of field name conflicts we give preference to <code>A</code>.</p>