You can use histc
, which allows to specify the edges of the histogram bins. It doesn't compute relative frequencies or print a table though, you have to do this yourself:
% error data
e = [2, 5, 2, 8, 2, 3, 5, 6, 1, 0, 2, 0, 1, 5, 0, 0, 4, 5, 1, 2];
% bin edges
be = 0 :2: ceil(max(e) / 2) * 2;
% absolute frequencies
af = histc(e, be);
% relative frequencies
rf = af / sum(af);
% print table
fprintf(' Value Count Percent\n')
fprintf(' %d-%d\t %d\t %5.2f%%\n', [be; be + 1; af; rf * 100])
The result is:
Value Count Percent
0-1 7 35.00%
2-3 6 30.00%
4-5 5 25.00%
6-7 1 5.00%
8-9 1 5.00%