arencode.m
资源名称:work.rar [点击查看]
上传用户:hwtw888
上传日期:2016-03-15
资源大小:177k
文件大小:1k
源码类别:
压缩解压
开发平台:
Matlab
- function arcode = arencode(symbol, pr, seqin)
- %算术编码
- %输出:码串
- %输入:symbol:字符行向量
- % pr:字符出现概率
- % seqin:待编码字符串
- high_range = [];
- for k = 1: length(pr),
- high_range = [high_range sum(pr(1: k))];
- end
- low_range = [0 high_range(1: length(pr) - 1)];
- sbidx = zeros(size(seqin));
- for i = 1: length(seqin),
- sbidx(i) = find(symbol == seqin(i));
- end
- low = 0; high = 1;
- for i = 1: length(seqin),
- range = high - low;
- high = low + range * high_range(sbidx(i));
- low = low + range * low_range(sbidx(i));
- end
- arcode = low;