Question: From the following code in Matlab, pass it to mathematical calculations with the word UAM and rectify its result with the code already provided clc
From the following code in Matlab, pass it to mathematical calculations with the word "UAM" and rectify its result with the code already provided
clc clear all variables
clear clear the screen
aux; auxiliary variable that helps us to consider bits of memory
Initialize counters of the cases to zero etc...
cont;
cont;
cont;
cont;
cont;
cont;
cont;
cont;
Initialize counters of the cases to zero
cont;
cont;
cont;
cont;
General counter to
conta;
Enter the message
strinputEnter the message: ;
auxEndecbinstr;convert the message to binary each character to bit binary
separate bit by bit
for t:lengthstr
for t:
EnttbindecauxEntt;
end
end
Concatenate all the bits to have it in a vector
conte;
for k:lengthEn:
for k:
PauxconteEnkk;
conteconte;
end
end
MPaux;
for k:lengthM
if kFor the first iteration, both aux values equal which is of no use to us; they must be or
aux; first aux value
aux; second aux value
else from the second iteration onwards
auxaux; We scan the values in memory, the second value takes the value of the first
auxMk; The first value of aux takes the first value of the message
end
if kFrom the third iteration, these are already favorable cases or events, the values in the memory are already different from
contaconta;the favorable case is counted
if MkCases for when the information bit is
if aux && auxIt asks if the memory has
Increments counters
contcont;
contcont;
elseif aux && auxIt asks if the memory has
Increments counters
contcont;
contcont;
elseif aux && auxAsks if the memory has
Increments counters
contcont;
contcont;
else Asks if the memory has
Increments counters
contcont;
contcont;
end
else Same procedure, for when the information bit is
if aux && aux
contcont;
contcont;
elseif aux && aux contcont;
contcont;
elseif aux && aux contcont;
contcont;
else contcont;
contcont;
end
end
end
end
Probabilities are calculated considering favorable cases among total cases
P P P etc.
Pcontcont;
Pcontcont;
Pcontcont;
Pcontcont;
Pcontcont;
Pcontcont;
Pcontcont;
Pcontcont;
Probabilities are calculated considering favorable cases among total cases
P P P P Pcontcount;
Pcontcount;
Pcontcount;
Pcontcount;
Vectors are generated with the probability calculated for the case of and ProbasP P P P;
ProbasP P P P;
TeststatesP P P P;
The denominator is calculated sum;
for k:lengthProbas auxProbaskProbastatesk;
auxTestkTeststatesk;
sumsumauxaux;
end Vectors are generated to calculate the final probabilities ProbasP P P P P P P P;
StatesP P P P P P P P;
Final probabilities are calculated for k:lengthProbas PkProbaskStatesksum;
end Entropy is calculated for k:lengthP if Pk Rk;
else RkPklogPk;
end end Entropy HsumR
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
