h=[1,0,0,0,0,0,0,0;1,1,0,0,0,0,0,0;0,1,1,0,0,0,0,0;1,0,1,1,0,0,0,0;0,1,0,1,1,0,0,0;0,0,1,0,1,1,0,0;0,0,0,1,0,1,1,0;1,0,0,0,1,0,1,1;0,1,0,0,0,1,0,1;0,0,1,0,0,0,1,0;0,0,0,1,0,0,0,1;0,0,0,0,1,0,0,0;0,0,0,0,0,1,0,0;0,0,0,0,0,0,1,0;0,0,0,0,0,0,0,1]; b=flipud(h); s=r*b; for i=1:8
if rem(abs(s(i)),2)==0 s(i)=0;end end for i=1:8
if rem(abs(s(i)),2)==1 s(i)=1;end end
if s==[0 0 0 0 0 0 0 0]
e=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; elseif s==[1 0 0 0 0 0 0 0]
e=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]; elseif s==[1,1,0,0,0,0,0,0]
e=[0 0 0 0 0 0 0 0 0 0 0 0 0 1 0]; elseif s==[0,1,1,0,0,0,0,0]
e=[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]; elseif s==[1,0,1,1,0,0,0,0]
e=[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]; elseif s==[0,1,0,1,1,0,0,0]
e=[0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]; elseif s==[0,0,1,0,1,1,0,0]
e=[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]; elseif s==[0,0,0,1,0,1,1,0]
e=[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]; elseif s==[1,0,0,0,1,0,1,1]
18
e=[0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]; elseif s==[0,1,0,0,0,1,0,1]
e=[0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; elseif s==[0,0,1,0,0,0,1,0]
e=[0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]; elseif s==[0,0,0,1,0,0,0,1]
e=[0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]; elseif s==[0,0,0,0,1,0,0,0]
e=[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]; elseif s==[0,0,0,0,0,1,0,0]
e=[0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]; elseif s==[0,0,0,0,0,0,1,0]
e=[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]; else s==[0,0,0,0,0,0,0,1]
e=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; end u=r+e; for i=1:15
if rem(abs(u(i)),2)==0 u(i)=0;end end for i=1:15
if rem(abs(u(i)),2)==1 u(i)=1;end end
Data=zeros(1,7); Data(1)=u(9); Data(2)=u(10); Data(3)=u(11); Data(4)=u(12);
19
Data(5)=u(13); Data(6)=u(14); Data(7)=u(15);
if e==[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] disp('没有错误:') k=0,else
disp('第几位错误:') k=find(e) end
disp('接收码字') r
disp('译码输出序列:') Data
%4将编码输出改错一位之后,验证程序的纠错能力 clear; clc;
r=[0 0 1 1 0 1 1 1 1 1 1 0 0 0 1];
h=[1,0,0,0,0,0,0,0;1,1,0,0,0,0,0,0;0,1,1,0,0,0,0,0;1,0,1,1,0,0,0,0;0,1,0,1,1,0,0,0;0,0,1,0,1,1,0,0;0,0,0,1,0,1,1,0;1,0,0,0,1,0,1,1;0,1,0,0,0,1,0,1;0,0,1,0,0,0,1,0;0,0,0,1,0,0,0,1;0,0,0,0,1,0,0,0;0,0,0,0,0,1,0,0;0,0,0,0,0,0,1,0;0,0,0,0,0,0,0,1]; b=flipud(h); s=r*b; for i=1:8
if rem(abs(s(i)),2)==0 s(i)=0;end end for i=1:8
if rem(abs(s(i)),2)==1 s(i)=1;end end
20
if s==[0 0 0 0 0 0 0 0]
e=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; elseif s==[1 0 0 0 0 0 0 0]
e=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]; elseif s==[1,1,0,0,0,0,0,0]
e=[0 0 0 0 0 0 0 0 0 0 0 0 0 1 0]; elseif s==[0,1,1,0,0,0,0,0]
e=[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]; elseif s==[1,0,1,1,0,0,0,0]
e=[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]; elseif s==[0,1,0,1,1,0,0,0]
e=[0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]; elseif s==[0,0,1,0,1,1,0,0]
e=[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]; elseif s==[0,0,0,1,0,1,1,0]
e=[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]; elseif s==[1,0,0,0,1,0,1,1]
e=[0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]; elseif s==[0,1,0,0,0,1,0,1]
e=[0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; elseif s==[0,0,1,0,0,0,1,0]
e=[0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]; elseif s==[0,0,0,1,0,0,0,1]
e=[0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]; elseif s==[0,0,0,0,1,0,0,0]
e=[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]; elseif s==[0,0,0,0,0,1,0,0]
e=[0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]; elseif s==[0,0,0,0,0,0,1,0]
e=[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0];
21
else s==[0,0,0,0,0,0,0,1]
e=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; end u=r+e; for i=1:15
if rem(abs(u(i)),2)==0 u(i)=0;end end for i=1:15
if rem(abs(u(i)),2)==1 u(i)=1;end end
Data=zeros(1,7); Data(1)=u(9); Data(2)=u(10); Data(3)=u(11); Data(4)=u(12); Data(5)=u(13); Data(6)=u(14); Data(7)=u(15);
if e==[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] disp('没有错误:') k=0,else
disp('第几位错误:') k=find(e) end
disp('接收码字') r
disp('译码输出序列:') Data
22
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库循环码的编译码方法..(5)在线全文阅读。
相关推荐: