Huffman Coding Toolbox Huffman Coding Toolbox histcalc

Huffman Coding Toolbox >> Huffman Coding Toolbox > fasthist

fasthist

fast calculation of histogram

Calling Sequence

H=fasthist(x)

Parameters

H:

sparse vector, containing the number of entries of the matrix/vector A. A is converted inside the function to INT.

A:

A is a vector or matrix with positive numbers. The number of occurences of numbers is counted.

Description

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)).

Examples

// 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);

See also

Authors

Huffman Coding Toolbox Huffman Coding Toolbox histcalc