Code covered by the BSD License  

Highlights from
Contemporary Communications Systems Matlab Files

image thumbnail

Contemporary Communications Systems Matlab Files

by

 

Matlab Files in this book

h=entropy(p)
function h=entropy(p)
%		H=ENTROPY(P) returns the entropy function of 
%		the probability vector p.
if length(find(p<0))~=0,
  error('Not a prob. vector, negative component(s)')
end
if abs(sum(p)-1)>10e-10,
  error('Not a prob. vector, components do not add up to 1')
end
h=sum(-p.*log2(p));

Contact us