No BSD License  

Highlights from
Huffman

image thumbnail
from Huffman by Jaun Dough
Generates a static minimum-variance Huffman code tree.

demo.m
% Demonstrates how to use huffman.m

clear all;
home;

% Number of source symbols
N = 20;

W = zeros(N, 1);
for i = 1:length(W)
	% weight of this source symbol
	W(i) = i;

	% label for this source symbol
	L{i} = sprintf('I am node #%d',W(i));
end

% size of output code alphabet (e.g. D = 2 for binary)
D = 2;

% generate Huffman code and display code tree on the screen
C = huffman(D, W, L, 'screen')

% generate Huffman code and display code tree on the screen and using
% Graphviz DOT
C = huffman(D, W, L, 'screen', 'dot')

Contact us at files@mathworks.com