No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

3.2 | 8 ratings Rate this file 10 Downloads (last 30 days) File Size: 9.58 KB File ID: #228 Version: 1.0



Karl Skretting (view profile)


A set of MATLAB m-files (version 5.2) which do complete Huffman Coding.

| Watch this File

File Information

A set of MATLAB m-files (version 5.2) which do complete Huffman Coding.
The files are:
hufflen: Based on probability (or number of occurences) of each symbol the length for the Huffman codewords are calculated.
          ex: HL = hufflen(S);
huffcode: Based on the codeword lengths this function find the Huffman codewords
          ex: HK = huffcode(HL);
hufftree: Make the Huffman-tree from the length of Huffman codes
          ex: Htree = hufftree(HL);
huff03: Huffman encoder/decoder, one or two vectors of non-negative integers are huffman coded.
          ex: y = huff03(x1, x2); % encoding
          ex: [x1, x2] = huff03(y); % decoding

MATLAB release MATLAB 5.2 (R10)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
21 Jan 2016 Karl Skretting

Authors remark:
A newer zip-file is now available from

Comment only
12 Nov 2007 milind tandel

12 Mar 2007 Faisal Alhajri

It`s not bad. However, I think you can make it more simple and efficient. It`s too long and it needs three other function beside the orginal one, you can combine them in one function and much less lines. it's going to be then more faster in execution and less error. I have made one but still in progress. anyway, mine is much less lines than this one. You are like trying to execute 1+1 in this manner y = 1, x = 1, and z = y, s = x, then g = z + s.
Good luck man.

25 Dec 2006 mickey mickey


25 Oct 2005 bala sundaram

its really nice


the coding process is not running correctly it fails in encoding itself help for it

21 Apr 2004 George Castle

I tried using a square wave with a long period and the compression was no different than for a random sequence. There appears to be a bug that needs fixing first.

19 Apr 2004 Afshin David

Doesn't seem to work, e.g., for a constant sequence it gives irrelevant codewords.

05 Dec 2003 akam paul

I try it

Contact us