MATLAB: How to define the bin size for a histogram

histogram

Hello
I have 2 questions.
I am trying to create 100 bins for my histograms which covers actually 10000 data points. The command bincounts = histc(x,binranges), allows me to put the binranges value but I dont want to repeat (0 100 200……….10000)as the value for 'binranges'. So is there any shorter way to give that kind of argument for binranges to use that command. Once I know that, I can use bar(binranges,bincounts,'histc') to plot the histogram.
Second question, how do I normalize the area of the histogram to be 1.
Thanks

Best Answer

There are two histogram functions in matlab. The other one, hist allows you to specify the number of bins instead of the edges.
As for normalising:
dist = hist(data, 100);
dist = dist / sum(dist);