You are on page 1of 1

%Huffman Coding for English Alphabets

% By Anteneh Amsalu Enyewu ID GSE/1077/08


% ************************

% Setup the MATLAB console


%The first piece of code in this program initializes the MATLAB console by clearing all existing state
%(variables, figures, etc.)
clc;
clear all;
close all;
%Let’s assign symbols from space as 1 and from a to z by 2 to 27.

symbols = [1:27]; % which lists the distinct signal values that the source produces Probability

P=[ 0.186 0.103 0.08 0.064 0.063 0.058 0.057 0.051 0.048
0.047 0.032 0.032 0.023 0.022 0.021 0.02 0.017 0.016
0.015 0.015 0.013 0.008 0.005 0.001 0.001 0.001 0.001];
Dictionary= huffmandict(symbols,P);

for i=1: length(Dictionary)


Dictionary {i,2}= num2str(Dictionary{i,2});
end
disp(Dictionary);
hcode=huffmanenco(symbols,Dictionary)% encodes the signal sig using the Huffman described by
%the code dictionary codes

%dhsig= huffmandeco(hcode, dict)%if decoding required

You might also like