How Huffman Key is getting generated in this

1 visualización (últimos 30 días)
Alpesh Saxena
Alpesh Saxena el 2 de Oct. de 2019
Editada: KALYAN ACHARJYA el 10 de Oct. de 2019
function [key] = keyGen(n)
n = n*8;
bin_x = zeros(n,1,'uint8');
r = 3.9999998;
bin_x_N_Minus_1 = 0.300001;
x_N = 0;
for ind = 2 : n
x_N = 1 - 2* bin_x_N_Minus_1 * bin_x_N_Minus_1;
if (x_N > 0.0)
bin_x(ind-1) = 1;
end
bin_x_N_Minus_1 = x_N;
end
t = uint8(0);
key = zeros(n/8,1,'uint8');
for ind1 = 1 : n/8
for ind2 = 1 : 8
key(ind1) = key(ind1) + bin_x(ind2*ind1)* 2 ^ (ind2-1);
end
end

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 10 de Oct. de 2019
Editada: KALYAN ACHARJYA el 10 de Oct. de 2019
How Huffman Key is getting generated in this?
Is this?
function [key] = keyGen(n)
n = n*8;
bin_x = zeros(n,1,'uint8');
r = 3.9999998;
bin_x_N_Minus_1 = 0.300001;
x_N = 0;
for ind = 2 : n
x_N = 1 - 2* bin_x_N_Minus_1 * bin_x_N_Minus_1;
if (x_N > 0.0)
bin_x(ind-1) = 1;
end
bin_x_N_Minus_1 = x_N;
end
t = uint8(0);
key = zeros(n/8,1,'uint8');
for ind1 = 1 : n/8
for ind2 = 1 : 8
key(ind1) = key(ind1) + bin_x(ind2*ind1)* 2 ^ (ind2-1);
end
end
Command Window: or call the function from other matlab Main Script
>> b=keyGen(10)
b =
10×1 uint8 column vector
149
120
105
134
227
246
246
121
30
77

Categorías

Más información sobre Large Files and Big Data en Help Center y File Exchange.

Productos


Versión

R2013a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by