MATLAB: How to use histogram(data, num_bins)

histogram

I have a 8945×1 double array, and I want to view it's distribution, as a histogram
first try: histogram(data), here's what I get:
second try: using histogram(data, 20):
what am I doing wrong?
data is attached as an excel file if anybody cares to investigate
thanks!

Best Answer

The reason is that you have a very sharply peaked histogram with a very long tail. The default binning, and your 20-bin option, just don't capture the range well. Try this:

figure
histogram(data,[0:0.1:5 Inf])
xlim([0 5])

I've defined the edges of the bins as a vector. The result looks like this: