📄 pushbutton23.m
字号:
% s22,M个元素,信道解码结果
% u=[1 0 1 1 1 0 0] %信源码
% c=[1 1 1 0 0 0 0 1 1 0 0 1 1 1]%卷积编码结果
% y=[1 1 1 0 0 0 0 1 1 0 0 1 1 1]; %s22,s22信道传输后接收端的码元
LL=2;%表示第几步
PM1=[0 0 0 0]; %路径存储器00 00 00 00表示最上面的一条路径
temp1=s22(1:2*LL);temp2=XOR(temp1,PM1);temp3=find(temp2==1);MM1=length(temp3);uu1=[0 0];
PM2=[0 0 1 1];
temp1=s22(1:2*LL);temp2=XOR(temp1,PM2);temp3=find(temp2==1);MM2=length(temp3);uu2=[0 1];
PM3=[1 1 1 0];
temp1=s22(1:2*LL);temp2=XOR(temp1,PM3);temp3=find(temp2==1);MM3=length(temp3);uu3=[1 0];
PM4=[1 1 0 1];
temp1=s22(1:2*LL);temp2=XOR(temp1,PM4);temp3=find(temp2==1);MM4=length(temp3);uu4=[1 1];
for LL = 3:M/2,
PM1_1=[PM1,0,0];
PM1_2=[PM3,1,1];
uu1_1=[uu1,0];
uu1_2=[uu3,0];
temp1=s22(1:2*LL);
temp2=XOR(temp1,PM1_1);temp3=find(temp2==1);MM1_1=length(temp3);
temp2=XOR(temp1,PM1_2);temp3=find(temp2==1);MM1_2=length(temp3);
PM2_1=[PM1,1,1]; %PM2_1表示到达状态b的第一条路径
PM2_2=[PM3,0,0];
uu2_1=[uu1,1];
uu2_2=[uu3,1];
temp1=s22(1:2*LL);
temp2=XOR(temp1,PM2_1);temp3=find(temp2==1);MM2_1=length(temp3);
temp2=XOR(temp1,PM2_2);temp3=find(temp2==1);MM2_2=length(temp3);
PM3_1=[PM2,1,0];
PM3_2=[PM4,0,1];
uu3_1=[uu2,0];
uu3_2=[uu4,0];
temp1=s22(1:2*LL);
temp2=XOR(temp1,PM3_1);temp3=find(temp2==1);MM3_1=length(temp3);
temp2=XOR(temp1,PM3_2);temp3=find(temp2==1);MM3_2=length(temp3);
PM4_1=[PM2,0,1];
PM4_2=[PM4,1,0];
uu4_1=[uu2,1];
uu4_2=[uu4,1];
temp1=s22(1:2*LL);
temp2=XOR(temp1,PM4_1);temp3=find(temp2==1);MM4_1=length(temp3);
temp2=XOR(temp1,PM4_2);temp3=find(temp2==1);MM4_2=length(temp3);
if MM1_1<=MM1_2,
MM1=MM1_1;PM1=PM1_1;uu1=uu1_1;
else
MM1=MM1_2;PM1=PM1_2;uu1=uu1_2;
end
if MM2_1<=MM2_2,
MM2=MM2_1;PM2=PM2_1;uu2=uu2_1;;
else
MM2=MM2_2;PM2=PM2_2;uu2=uu2_2;
end
if MM3_1<=MM3_2,
MM3=MM3_1;PM3=PM3_1;uu3=uu3_1;
else
MM3=MM3_2;PM3=PM3_2;uu3=uu3_2;
end
if MM4_1<=MM4_2,
MM4=MM4_1;PM4=PM4_1;uu4=uu4_1;
else
MM4=MM4_2;PM4=PM4_2;uu4=uu4_2;
end
end
%%得到最后的结果
Last_MM=MM1;PM=PM1;uu=uu1;
if Last_MM>=MM2,
Last_MM=MM2;PM=PM2;uu=uu2;
end
if Last_MM>=MM3,
Last_MM=MM3;PM=PM3;uu=uu3;
end
if Last_MM>=MM4,
Last_MM=MM4;PM=PM4;uu=uu4;
end
s23=uu;
Last_MM = Last_MM,
nnn=1:M/2;
figure(23)
set(23,'Position',[10,50,500,200])
stem(nnn,s23);
axis([0,20,-1,1]);
grid;
s3xor23=xor(s3,s23);
e_No=find(s3xor23==1);
e_num=length(e_No);
if e_num>20,
e_No=e_No(1:21);
e_No=num2str(e_No);
e_num=num2str(e_num);
e_num=[e_num,'个错误,显示前20个']
msgbox(e_No,e_num);
else
e_No=num2str(e_No);
e_num=num2str(e_num);
e_num=[e_num,'个错误'];
msgbox(e_No,e_num);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -