Products & Services Solutions Academia Support User Community Company

Learn more about Communications Toolbox   

huffmandeco - Huffman decoder

Syntax

dsig = huffmandeco(comp,dict)

Description

dsig = huffmandeco(comp,dict) decodes the numeric Huffman code vector comp using the code dictionary dict. The argument dict is an N-by-2 cell array, where N is the number of distinct possible symbols in the original signal that was encoded as comp. The first column of dict represents the distinct symbols and the second column represents the corresponding codewords. Each codeword is represented as a numeric row vector, and no codeword in dict is allowed to be the prefix of any other codeword in dict. You can generate dict using the huffmandict function and comp using the huffmanenco function. If all signal values in dict are numeric, dsig is a vector; if any signal value in dict is alphabetical, dsig is a one-dimensional cell array.

Examples

The example below encodes and then decodes a vector of random data that has a prescribed probability distribution.

symbols = [1:6]; % Distinct symbols that data source can produce
p = [.5 .125 .125 .125 .0625 .0625]; % Probability distribution
[dict,avglen] = huffmandict(symbols,p); % Create dictionary.
actualsig = randsrc(1,100,[symbols; p]); % Create data using p.
comp = huffmanenco(actualsig,dict); % Encode the data.
dsig = huffmandeco(comp,dict); % Decode the Huffman code.
isequal(actualsig,dsig) % Check whether the decoding is correct.

The output below indicates that the decoder successfully recovered the data in actualsig.

ans =

     1

See Also

huffmandict, huffmanenco, Huffman Coding

References

[1] Sayood, Khalid, Introduction to Data Compression, San Francisco, Morgan Kaufmann, 2000.

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS