MATLAB程序 信源编码.docVIP

  • 89
  • 0
  • 约3.34千字
  • 约 4页
  • 2020-12-17 发布于浙江
  • 举报
计算信源熵的MATLAB源程序 function H=entropy(P,r) if (length(find(P=0))~=0) error(Not a prob.vector,negative component); end if(abs(sum(P)-1)10e-10) error(Not a prob.vector,component do not add up to 1); end H=(sum(-P.*log2(P)))/(log2(r)+eps); 香农编码的MATLAB源程序 function [s,L,q]=shannon(p) %if(length(find(p=0))~=0) % error(Not a prob.vector,negative component); %end %if(abs(sum(p)-1)10e-10) % error(Not a prob.vector,component do not add up to 1) %end n=length(p); x=1:n; [p,x]=array(p,x); l=ceil(-log2(p)); P(1)=0; n=length(p); for i=2:n P(i)=P(i-1)+p(i-1); end for i=1:

文档评论(0)

1亿VIP精品文档

相关文档