title: In matlab how can I save a histogram from command line?
body: <p>I have a large number of files that I need to make histograms for therefore I want to save it from the command line. For plots I usually save it in matlab using the following command:</p>
  
  <pre><code>figure = plot (x,y)
  saveas(figure, output, 'jpg')
  </code></pre>
  
  <p>I want to do the same for histograms:</p>
  
  <pre><code>figure = hist(x)
  saveas(figure, output, 'jpg')
  </code></pre>
  
  <p>However I get an error that says incorrect handle. I also tried <code>imwrite</code> function, the code executes but saves a blank black image. Is there a way in which I will be able to save my histograms? </p>