Exp 3 Entropy

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

%AIM: To plot the entropy function for M=2.

x=linspace(0.00001,0.99999,100);
for i = 1:100
p=x(i);
h(i)=-p*log2(p) - (1-p)*log2(1-p);
end
plot(x,h);
xlabel('probability');
ylabel('entropy');
title('entropy function for M=2');

You might also like