title: How does one concatenate cell arrays that are part of a cell array in MATLAB?
body: <p>I have a cell array <code>allData</code> which is Nx1. Each cell contains a structure with a <code>names</code> property (the name is a custom object, but think of it as a cell array of strings if you like). I would like to create a single cell array that contains all of the names. For example, if N=3, so that <code>allData</code> is a 3x1 cell array, then the following would accomplish my goal:</p>
  
  <pre><code>A = allData{1};
  B = allData{2};
  C = allData{3};
  
  allNames = [A.names B.names C.names];
  </code></pre>
  
  <p>The problem with this approach is that N is large and changes depending on the input, so I'm hoping that there is a clever way to do this using <code>cellfun</code>, but everything that I've tried fails (e.g. it doesn't work to do <code>allNames = [cellfun(@(x) {x.names}, allData)];</code>).</p>
  
  <p><strong>UPDATE:</strong> Thanks to the suggested solutions, I can get everything into one cell array where each cell contains a cell array. My goal here is to concatenate these. More or less, what I have is:</p>
  
  <pre><code>{A.names B.names C.names} 
  </code></pre>
  
  <p>and what I want and cannot seem to get is</p>
  
  <pre><code>{A.names{1} A.names{2} ... A.names{end} B.names{1} ... B.names{end} ...}
  </code></pre>
  
  <p><strong>SOLUTION</strong>:
  I needed pieces of each answer below, so here's the solution that worked for me:</p>
  
  <p>from <a href="https://stackoverflow.com/users/717898/andrew-lazarus">Andrew Lazarus</a>: </p>
  
  <p><code>allNames = arrayfun(@(x) x.name, [allData{:}], 'UniformOutput', false);</code></p>
  
  <p>then, from <a href="https://stackoverflow.com/users/52738/gnovice">gnovice</a>:</p>
  
  <p><code>allNames = vertcat(allNames{:});</code></p>
  
  <p>Thanks to both!!</p>