MATLAB: How to change step interval in a frequency table in matlab

frequency tabletabulate

Hi all!
I have created a frequency table as follows:
A = [220 200 170 160 150 165 200 300 350 400 400 350 380 360 350 330 300 350 400 420 480 550 500 350];
B = tabulate(A);
Which results in 550×3 table, starting from 1 up to the maximum value of A, how do I limit it only to those 24 values?

Best Answer

The help of TABULATE states: If the elements of X are non-negative integers, then the output includes 0 counts for any integers that are between 1 and max(X) but do not appear in X.
I do not know the reason behind this behaviour, but it does suggest the following solution: 1. add a negative value to the input 2. remove this entry after tabulation
A = [5 5 7 10 10 10]
B = tabulate([A(:) ; -Inf])
B = B(2:end,:)
Related Question