title: Histogram rebinning in Matlab 2020a, when I don't have a Matlab histogram object
body: <p>I have two vectors that describe a histogram: bin values/labels and bin count.
  I'd like to import those into a Matlab histogram object so that I can change parameters more easily, such as the number of bins.
  Here is a simplification what I have:
  Center bin values:</p>
  <pre><code>BinValues(1:21) = [-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10];
  </code></pre>
  <p>and count values per bin</p>
  <pre><code>CountValues(1:21) = [ 16 12 3 21 7 8 2 6 0 3 4 6 1 8 3 25 16 5 7 10 16];
  </code></pre>
  <p>My actual histogram has 800000 bins, and I want to vary the number of bins.</p>
  <p>In my simplified example above, it would be something like reducing the bins from 21 to 15 or 21 to 11.</p>
  <p>What I have can be graphed as a simple bar graph.</p>
  <pre><code> bar(BinValues,CountValues);
  </code></pre>
  <p>But, if I want to experiment with different numbers of bins, I think it would be best to use the histogram function/object in Matlab, but I'm not sure how I do this from what I have.</p>
  <p>OK Update:</p>
  <p>I tried this:</p>
  <pre><code> h=histogram('BinEdges',[-10.5:10.5] , 'BinCounts', CountValues);
  </code></pre>
  <p>Now I have a nice histogram, but if I use fewerbins(h), I get an error saying I can't do that while BinCountsMode is in &quot;manual&quot;. If I modify it to be in &quot;auto&quot; mode, then my original histogram disappears.</p>
  <p>The brute force solution would be to generate a huge array with repeated values as dictated by binCount values, but that seems like a dumb way to solve this problem.</p>