資源簡介
本程序使用Matlab語言實現了huffman,哈夫曼編碼,包括對二進制文檔的編碼,注釋清楚。

代碼片段和文件信息
function?deseq=huffdecode(hufenseq)
%decode?the?code?that?encode?the?source
l=length(enseq);
h=length(huf);
%acquire?the?huffman?code?for?each?symbol?
for?i=1:h
hufcode(i)=huf(i).code;
end
deseq=‘‘;
str=‘‘;
?for?i=1:l
????str=[str?enseq(i)];
????idx=find(strcmp(strhufcode));
????%replace?the?code?with?the?corresponding?symbol
????if?~isempty(idx)
????????deseq=[deseq?huf(idx).sym];
????????str=‘‘;
????end
?end
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2009-09-24?00:22??源程序
?????文件???????4991??2009-09-24?00:19??源程序\decode.txt
?????文件??????23434??2009-09-24?00:19??源程序\encode.txt
?????文件????????438??2009-09-23?23:24??源程序\huffdecode.m
?????文件????????349??2009-09-23?23:26??源程序\huffencode.m
?????文件???????3079??2009-09-24?00:16??源程序\huffman.m
?????文件???????1496??2009-09-24?00:11??源程序\main.m
?????文件????????560??2009-09-23?23:46??源程序\probability.m
?????文件???????4991??2009-09-24?00:18??源程序\source.txt
?????文件??????39424??2009-09-24?00:21??文檔.doc
-----------?---------??----------?-----??----
????????????????78762????????????????????10
- 上一篇:ExOR算法 的 matlab 實現
- 下一篇:PMSM無速度傳感器DTC控制
評論
共有 條評論