信息理论与编码课后答案第5章

发布时间 : 星期一 文章信息理论与编码课后答案第5章更新完毕开始阅读

% m=zeros(K,2^K); % 信息组初始化 for i=0:2^K-1

seq=dec2bin(i,K); for j=1:K

m(i+1,j)=str2num(seq(j)); end end

c=mod(m*G,2); 生成所有信息组对应的码字 程序说明:

(5) 生成矩阵G和信息组m是已知的

(6) 本程序对所有的信息组进行了编码,如果只需要对特定信息组进行编码,修改m即可 (7) str2num:实现字符串向数字的转换 (8) mod:求模函数

运行结果:

所有可能的信息组为: m =

0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1

生成所有信息组对应的码字为: c =

0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 0 (2)译码过程

function codeword=lincoder(H,y) % H:校验矩阵

% y:接收到的矢量

% codeword:估计发送的矢量,返回值

[r,N]=size(H); % 确定校验位个数和码长 s=mod(H*y',2); % 确定伴随式 k=N-r; % 确定信息位个数 e_common=zeros(N,k); bas=eye(k); for i=1:k

e_common(1:k,i)=bas(:,i); for index=1:r

e_common(k+index,i)=mod(H(index,1:k)*e_common(1:k,i),2); % 确定通解 end end

e_special=zeros(N,1); e_special(1:k)=0; for index=1:r

e_special(k+index)=mod(H(index,1:k)*e_special(1:k)+s(index),2); % 确定特解 end

% 以下构成系数的所有组合 e=zeros(N,2^k); coef=zeros(2^k,k); for i=0:2^k-1

seq=dec2bin(i,k); for j=1:k

coef(i+1,j)=str2num(seq(j)); % 确定系数 end end

for index=1:2^k for i=1:k

e(:,index)=e(:,index)+coef(index,i)*e_common(:,i); end end

e=mod(e,2); for i=1:2^k

e(:,i)=e(:,i)+e_special; % 确定全解 end

e=mod(e,2); % 模2和

weight=sum(e); % 求e的汉明重量

minimum=min(weight); % 找出汉明重量最小的差错图样

location=find(weight==minimum); %确定具有最小汉明重量的e的位置 location=location(1); % 可能有多个,择其一 err=e(:,location);

codeword=mod(y+err',2); 程序说明:

本程序并非使用陪集方法来译码,而是利用求解线性方程组的思路确定差错图样,进而译码。按照线性代数理论,方程HeT=s的未知数个数多于方程个数,e的理论值有无穷多个,但考虑到取值的有限性(仅0和1),e的个数也为有限个,可以确定所有e值,然后将汉明权重最小者作为差错图样。举例如下。

例 (5,3)线性码C,一致性校验矩阵H如下,如果接收到序列y=[10101],试确定发送的序列c

?10010?H???

11101??第一步,计算伴随式

?1??0??10010????1?Ts?Hy????1???1?

11101???????0???1??第二步,计算对应于s的陪集,即解如下方程:

HeT?s即?e1??e?2?10010????1? ?11101??e3???1????????e4???e5??解应该由通解和特解两部分构成,具有如下表达式

?0??1??0??1??1??1??1??0?????????Te?a?1??b?0??c?0???0?

????????01?????0??0?????0???0???1????0??abc 陪集 000 10000 001 11001 010 01011 011 00011 100 11100 101 10101 110 00111 111 01111 选择e=10000作为差错模式

第三步,得出码字的估计值

c=y?e??10101???10000???00101?

程序运行结果:

>> H=[1 0 0 1 0;1 1 1 0 1]; >> y=[1 0 1 0 1]; >> lincoder(H,y)

ans =

0 0 1 0 1

联系合同范文客服:xxxxx#qq.com(#替换为@)