No BSD License  

Highlights from
huffman.m

3.66667

3.7 | 6 ratings Rate this file 98 Downloads (last 30 days) File Size: 2.49 KB File ID: #227

huffman.m

by Sean Danaher

 

04 Jun 1998

Huffman

| Watch this File

File Information
Description

[CODE,COMPRESSION]=HUFFMAN5(P)

 P is the probability (or number of occurences) of each alphabet symbol
 CODE gives the huffman code in a string format of ones and zeros
 COMPRESSION gives the compression rate

 Huffman5 works by first building up a binary tree (eg p =[ .5 .2 .15 .15])

 Such that the tree always terminates at an alphabet symbol and the symbols furthest away from the root have the lowest probability. The branches at each level are labeled 0 and 1.
 
For this example CODE would be
     1
     00
     010
     011
 and the compression rate 1.1111

MATLAB release MATLAB 5.2 (R10)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
14 Feb 2003 Santhosh Nadig

Its a very good and straight forward implementation. Lacks a few comments in 'getcodes2' funciton.

06 Apr 2003 kapil chaudhari

This is a great code. It helped me very
much.

13 Apr 2003 anon anon

good

05 Jun 2003 Sridhar Bhat  
22 Sep 2003 Yong Li

A small bug in it.
line37 should be:
compression=ceil(log(length(p))/log(2))/ (sum(code' ~= ' ',1)*p);
in case of only [0;1] in code

19 May 2004 vinay A.P.

itz good filter design.it would be still wonderful if i would get the "CODE FOR ADAPTIVE NOISE CANCELLER IN MATLAB"
 which we are using it in voice password system
     thx sir
          vinay
  

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
dsp Sean Danaher 22 Oct 2008 06:34:16
huffman Sean Danaher 22 Oct 2008 06:34:16
binary Sean Danaher 22 Oct 2008 06:34:16
general dsp Sean Danaher 22 Oct 2008 06:34:16
signal processing Sean Danaher 22 Oct 2008 06:34:16
tree Sean Danaher 22 Oct 2008 06:34:16
general dsp zakri 28 Jan 2011 01:14:06

Contact us at files@mathworks.com