title: Merge cell array of maps by key in Matlab
body: <p>Given a cell array of <code>containers.Map</code> objects containing counts (values) for given events (keys). I would like to get a single map containing the sum of the counts (as values) for each key (or something allowing me to calculate the counts).</p>
  
  <p>For example:</p>
  
  <pre><code>maps = { containers.Map({'a','b'},{1,2}),
           containers.Map({'b','c'},{4,1}) };
  
  mergeMaps(maps)
  
    ans = Map(a -&gt; 1, b -&gt; 6, c -&gt; 1)
  </code></pre>
  
  <p>The only thing I could come up with so far is:</p>
  
  <pre><code>maps = { ... };
  res = containers.Map();
  for cMapC = maps
      cMap = cMapC{1};
      for cKeyC = keys(cMap{1})
          cKey = cKeyC{1};
          if isKey(res, cKey)
              res(cKey) = res(cKey) + cMap(cKey);
          else
              res(cKey) = cMap(cKey);
          end
      end
  end
  </code></pre>
  
  <p>Which should work (untested), but whose "efficiency" and readability is questionable to say the least. What is a better solution?</p>
  
  <p>Please note that currently there is no index attributed to events, so using sparse matrices instead of maps is cumbersome.</p>