Compute this in MATLAB Code Encode the following message in an optimal way Messa
ID: 3573587 • Letter: C
Question
Compute this in MATLAB Code Encode the following message in an optimal way Message = "fiveewillmewetweatwieefe" and calculate the entropy and number of bits for encoding the message. You can use any optimal encoding such as the Huffman, arithmetic, or Art code(s). Generate seven random pixels (x_n, y_n), n = 1:5, in the area of size 200 times 200 with the center at (128, 128). Hide the encoding message in the last insignificant bit-plane of the image "Lena" at pixels which start from the generated pixels (x_n, y_n), n = 1: 5, Display the results as shown in Figs. 1 and 2.
Explanation / Answer
Answer 1.
MATLAB code :
For a record length of 768 bytes, you can put 5 records in 4 KB page. You need to store 100,000 records, therefore you need 20,000 4 KB paes. Since a block is 64 pages, then you need 312 ful blocks and half of another block. So you need 313 blocks to store this file.
1024 MB = 1 GB
1024 KB = 1 MB
1 page = 4 KB
64 pages = 64 * 4 = 256 KB per block
256 KB - 1 block
1024*1024 KB = (?) block
Blocks = 4096 in 1 GB
200 GB = 4096 * 200 = 819200 Blocks
Each block can sustain with 50,000 flashes.
so we have total lifetime of 200 GB SSD = 819200 * 50000 = 40960000000 block-flashes
100000000 transaction each day assuming that no caching or buffering occur, so that each transaction result in page to be moved.
As 64 pages per block, so every 64 transaction 1 block is moved.
So that for 100000000 transaction 1562500 blocks moved.
%To encode given string
string = input('fiveewillmewetweatwieefe'); %input string
symbol = []; %initialize variables
count = [];
j=1;
for i=1:length(string)
flag=0;
flag=ismemeber(symbol,string(i));
if sum(flag)==0
symbol(j) = string(i);
k = ismember(string,string(i));
c=sum(k);
count(j) = c;
j=j+1;
end
end
ent=0;
total=sum(count);
%=========================loop to find entropy
%entropy
for i=1:1:size((count)');
prob(i) = count(i)/total;
ent=ent-prob(i)*log2(prob(i));
end
var=0;
%================function to create dictionary
[dict avglen]=huffmandict(symbol,prob);
temp = dict;
for i=1:length(temp)
temp{i,2} = num2str(temp{i,2});
var=var+(length(dict{i,2})-avglen)^2;
end
temp
%============encoder function
sig_encoded=huffmanenco(string,dict)
ent
avglen
var
For other questions you need to post it seperately.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.