title: Averaging a row of a cell array dependent on a string in another row
body: <p>I've got this cell-array:</p>
  
  <pre><code>times = {'plot'      'plot'      'plot'      'plot'      'plot'      'hist'      'plot'      'plot'      'plot'      'plot'  ;
           [0.0042]    [0.0026]    [0.0032]    [0.0054]    [0.0049]    [0.0106]    [0.0038]    [0.0026]    [0.0030]    [0.0026]}
  </code></pre>
  
  <p>now I want to create an average for each type in the first row and save it to an new cell like this:</p>
  
  <pre><code>result = {'hist'      'plot'  ;  
            [0.0106]    [0.0036];
            [     1]    [     9]}
  </code></pre>
  
  <p>The first row are the types, the second row are the averages and the third row are the number of elements.</p>
  
  <p>I solved my problem with this code:</p>
  
  <pre><code>labels = unique(times(1,:));
  result = cell(3,numel(labels));
  
  for i = 1 : numel(labels)
      result(1,i) = labels(i);
      times2avg = cell2mat(times(2,strcmp(times(1,:), labels(i))));
      result{2,i} = mean(times2avg);
      result{3,i} = numel(times2avg);
  end
  </code></pre>
  
  <p>My question now is whether there is an easier or more ideal solution to my problem.</p>