📄 code13.m
字号:
function co=code13(vi,vi_max)
%13折线编码
v=vi; %编码瞬时电平
vimax=vi_max;%编码器输入电平范围
e=5;
if v>0
c1=1;
else
c1=0;
v=-v;
end%码子正负位(第一位)
vv=(v/vimax)*4096;
if vv>2^(e+3)
c2=1;
if vv>2^(e+5)
c3=1;
if vv>2^(e+6)
c4=1;
else
c4=0;
end
else
c3=0;
if vv>2^(e+4)
c4=1;
else
c4=0;
end
end
else
c2=0;
if vv>2^(e+1)
c3=1;
if vv>2^(e+2)
c4=1;
else
c4=0;
end
else
c3=0;
if vv>2^e
c4=1;
else
c4=0;
end
end
end
d=[c2,c3,c4];%决定量化段的三个位
ii=[3:-1:1];
M=sum(d.*(2.^(ii-1)));
if M==0
s=0;
else
s=2^(e+M-1);
end
r=rem((vv-s),(2^M));
n=(vv-s-r)/(2^M);
if n==16
cduan1=[1,1,1,1];
else
for jj=1:4
t=rem(n,2);
n=(n-t)/2;
cduan1(jj)=t;
end
end%在分好的码段范围内进行16段的均匀线形编码,共四位
cduan=fliplr(cduan1);
co=[c1,d,cduan];%组成总的8位码子
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -