fast calculation of histogram
H=fasthist(x)
sparse vector, containing the number of entries of the matrix/vector A. A is converted inside the function to INT.
A is a vector or matrix with positive numbers. The number of occurences of numbers is counted.
The function fasthist uses sparse functions to calculate the histogram in a single step. No while loops are needed. The matrix A may contain positive numbers larger or equal 1.
The result vector h (sparse) represents the histogram, that means the number of occurences of elements of the vector A. H has the length max(int(a)).
// Generate a Testmatrix A=testmatrix('frk',10)+1; H1=fasthist(A); // Now, we add a constant to A... // let us see, what happens H2=fasthist(A+6); disp(H1); disp(H2);