Reproducing the Results of hist by the More Recent Function histogram of MATLAB

With release R2014b the new function histogram was introduced to replace the old function hist. Here is a script to reproduce the result of hist by the new function histogram.

According to the MATLAB documentation, unlike the hist function, the histogram function returns a histogram object that you can use to modify the properties of the histogram. Instead the output of the older hist function was the bin centers and the number of elements in each bin. To get these values, use the new function histcounts together with histogram. Here is a script to create the histogram plot together with the numerical output of the counts, bin centers and bin edges. First we create the histogram without using hist and histogram:

About me

I am a geoscientist, apl. professor of paleoclimate dynamics at the University of Potsdam. I have been using MATLAB since late 1992, especially for the analysis of paleoclimatic series. Please visit my university webpage http://martinhtrauth.de