Matlab Huffman code

This Matlab code generates a Huffman codebook for a specified set of symbol probabilities.

Copyright © 2010 Robert G. Maunder. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

19 Responses to “Matlab Huffman code”

  1. hugo Says:

    thank you very much

  2. saman Says:

    i need this realy.
    thx for help

  3. mahmoudawney Says:

    thank you very much.real i want this code.

  4. sandeepreddy Says:

    thank you very much sir

  5. neha Says:

    thnk you :)

  6. Michael Says:

    Thank you

  7. Liangjun Says:

    Thanks for your help

  8. Unknown Says:

    Thank you for the code. It’s awesome!

  9. Pooja shah Says:

    Can you plz tell me how to write Huffman code in matlab with user entering the probabilities and asking the user to enter the base for getting the huffman code.

  10. Rob Says:

    Hi Pooja Shah,

    The Matlab code that you can download from this page will generate a Huffman codebook for you, when you provide it with the symbol probabilities. Here is some code a Huffman encoder and decoder…

    Take care, Rob.

  11. divya Says:

    repeat accumulate code i need

  12. Rajesh N Says:

    Easy to understand. Very useful. Optimum coding

  13. Andrew Says:

    Hi Rob,

    Your program gives out Huffman Codes which are of a minimum length 2 bits for the highest probability. But the highest probability symbol should have a binary Huffman Code of only 1 bit. Could you please verify this?

  14. Andrew Says:

    Please ignore my previous question. I did not know the Huffman Code\’s algorithm properly. The code is perfect.

  15. kiyeob Says:

    I used this to make an dictionary but it failed the prefix free condition for long text files though it works for short text file.

  16. kiyeob Says:

    Actually I found it is not…I draw a tree from the codewords and found it is prefix-free code but somehow matlab recognizes this as prefix code…

  17. Rob Says:

    Hi Kiyeob,

    I hope you got this working - I can’t tell from your messages if you solved the problem or not…

    Take care, Rob.

  18. tiha Says:

    please i need a huffman code ^^

  19. Rob Says:

    Hello Tiha,

    You can download the code from…

    Take care, Rob.

Leave a Reply

Security Code: