title: Plot histogram from vector of counts
body: <p>If I have a vector of histogram edges and bin counts, is it possible to use this to directly generate a histogram plot?</p>
  
  <p>For example, given data vectors</p>
  
  <pre><code>edges = 0:10; % histogram edges for 9 bins
  counts = round(normpdf(edges(1:end-1), 5, 2) * 1000) % Generate bin counts
  
  counts =
  
       9    27    65   121   176   199   176   121    65    27
  </code></pre>
  
  <p>I can always generate the data artificially as</p>
  
  <pre><code>data = [];
  for i = 1:numel(counts)
    % This should be optimised by pre-allocating the data array,
    % but this is only provided as an example.
    data = [data (ones(1, counts(i)) * mean(edges(i:i+1)))];
  end
  </code></pre>
  
  <p>so that <code>numel(data) == sum(counts)</code> and I can then plot the histogram using <code>histogram(data, edges)</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/8kl8V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8kl8V.png" alt="enter image description here"></a></p>
  
  <p>However, I would like to do this without having to do the intermediary step of generating the artificial data as this seems rather convoluted.</p>
  
  <p>I know that I could use the <code>bar</code> function, but I would prefer to use <code>histogram</code> because I prefer the way that it plots and the functionality that it offers.</p>
  
  <p><strong>Edit:</strong> I'm using MATLAB R2015a / R2015b, although I would prefer to maintain backward compatibility with R2015a if possible (I know that there were fairly major changes to <code>histogram</code> in R2015b).</p>