⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arithscalecod.m

📁 一个详尽的算术编码的matlab仿真程序。
💻 M
字号:
function [tag mnm]=arithscalecod(alpha,prob,seq)
ls=length(seq);
l=0;u=1;
Fx(1)=0;
for i=1:length(prob)
    Fx(i+1)=Fx(i)+prob(i);
end
tag=[];
dif=[];
while ~isempty(seq)
    dif(end+1)=u-l;
    if l>=0 & u<0.5
        tag=strcat(tag,'0');
        l=2*l;
        u=2*u;
    elseif l>=0.5 & u<1
        tag=strcat(tag,'1');
        l=2*(l-0.5);
        u=2*(u-0.5);
    else
        p=find(seq(1)==alpha);
        l1=l+(u-l)*Fx(p);   
        u=l+(u-l)*Fx(p+1);
        l=l1;
        seq(1)='';
    end
end
wl=8;
b=numb2bin(u,wl);
tag=strcat(tag,b);
mnm=min(dif);
end

function b=numb2bin(l,wl)
b=[];
for i=1:wl
    v=l*2;
    f=floor(v);
    b=strcat(b,num2str(f));
    l=v-f;
end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -