title: Concatenating two or more struct-type variables in MATLAB
body: <p>Assuming types of all variables are <code>struct</code> and have same <code>fields</code> with <code>concatenatable</code> size (dimensions). For example:</p>
  
  <pre><code>a.x = 1; a.y = 2;
  b.x = 10; b.y = 20;
  </code></pre>
  
  <p>With the ordinary concatenation:</p>
  
  <pre><code>c = [a; b];
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>c(1).x = 1; c(1).y = 2;
  c(2).x = 10; c(2).y = 20;
  </code></pre>
  
  <p>What I want is:</p>
  
  <pre><code>c.x(1) = 1; c.y(1) = 2;
  c.x(2) = 10; c.y(2) = 20;
  </code></pre>
  
  <p>It can be done by:</p>
  
  <pre><code>c.x = [a.x; b.x];
  c.y = [a.y; b.y;];
  </code></pre>
  
  <p>However, if the variables have lots of fields,</p>
  
  <pre><code>a.x1 = 1;
  a.x2 = 2;
  % Lots of fields here
  a.x100 = 100;
  </code></pre>
  
  <p>It's a waste of time to write such a code. Is there any good way to do this?</p>