Compute this in MATLAB code Consider the following data for


Compute this in MATLAB code
Consider the following data for encoding the alphabet A_9: Show the Huffman code, ^1 fill the table and calculate the average length of the codewords, the entropy of the alphabet and the redundancy of the code: Encode the following message in an optimal way Message = {a_1a_2a_7a_3a_4a_9a_5a_2a-6a_1a_8a_2} and calculate the number of bits for encoding this message Write your code in MATLAB to encode this message.

Solution

For purpose of computing in matlab and for ease , we will define a1 by 1 , a2 by 2 and so on

The Matlab Code

symbols = 1:9 %%Here we define symbols as vector of values from 1 to 9

p=[0.34 , 0.28 ,0.24, 0.028, 0.0400,0.046,0.024,0.0004,0.0016]; %%The probability vector

dict = huffmandict(symbols,p); %% Calculating dictionary for Huffman Encoding

message=[1,2,7,3,4,9,5,2,6,1,8,2]; %% The message Vector

encoded_message= huffmanenco(message,dict); %% enco consists of huffman encoded message;

 Compute this in MATLAB code Consider the following data for encoding the alphabet A_9: Show the Huffman code, ^1 fill the table and calculate the average lengt

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site