1 sem octave lab 5

This commit is contained in:
Andrew 2019-12-01 15:44:42 +07:00
parent 018bac4688
commit df67329dea
2 changed files with 6 additions and 10 deletions

View file

@ -8,15 +8,11 @@ function [b,n] = calc_info(msg, alph, alph_p)
b = 0;
for i = 1:l_msg
flag = false;
for j = 1:l_alph
if msg(i) == alph(j)
flag = true;
b -= log(alph_p(j));
break
endif
endfor
if ~flag
mask = alph == msg(i);
if any(mask)
comp = alph_p(mask);
b -= log2(comp);
else
warning("[WARN] Symbol '%s' (at pos. %d from msg) not found in alphabet", msg(i), i)
endif
endfor