📄 puncture.asv
字号:
function punctureout=puncture(inputseq,seriencodedata,encoderate)
%inputa=[1 0 1 0 1 0;1 0 0 1 0 1];% in fact a is an inout bitstream
inputa=inputseq;
codedataA=inputa(1,:); % 分成两行的编码数据
codedataB=inputa(2,:);
nt=length(codedataA);
encoderate=3;
switch encoderate
case 1
punctureout1=seriencodedata; % rate 为1/2,直接输出串行编码序列
case 2
n=fix(nt*4/3); % rate 为3/4,凿孔操作,n为输出序列长度
na=n/2; % 行A和行B的长度
temp=zeros(1,n); % 输出序列的暂存变量
codestolenA=zeros(1,na);
codestolenB=zeros(1,na);
j=1;p=1;
for i=1:nt
if rem(i,3)~=0
codestolenA(j)=codedataA(i); % 对于行A,逢3的整数倍偷一个比特
j=j+1;
end
if rem(i+1,3)~=0
codestolenB(p)=codedataB(i); % 对于行B,逢3的整数倍减1偷一个比特
p=p+1;
end
end
puna=codestolenA; % stolen后的行A
punb=codestolenB; % stolen后的行B
j=1;p=1;
for i=1:n
if rem(i,2)~=0
temp(i)=puna(j);
j=j+1;
else
temp(i)=punb(p);
p=p+1;
end
end
punctureout1=temp;
case 3
n=fix(nt*3/2); % rate 为2/3,凿孔操作,n为输出序列长度
temp=zeros(1,n); % 输出序列的暂存变量
codestolenB=zeros(1,nt);
j=1;
for i=1:nt
if rem(i,2)~=0
codestolenB(j)=codedataB(i); % 对于行B,逢3的整数倍偷一个比特
j=j+1;
end
end
puna=codedataA; % 行A不变
punb=codestolenB; % stolen后的行B
j=1;p=1;
for i=1:n
if rem(i+1,3)==0
temp(i)=punb(j);
j=j+1;
else
temp(i)=puna(p);
p=p+1;
end
end
punctureout1=temp;
otherwise
punctureout1=seriencodedata; % rate 为1/2,直接输出串行编码序列
end
punctureout1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -