Matlab 如何解码LDPC

Matlab 如何解码LDPC,matlab,Matlab,我生成一个奇偶校验矩阵,并使用comm.LDPCEncoder对码字进行编码。但是,当我使用comm.LDPCDecoder对LLR进行解码时,解码的字与源不同。 你能帮我找出哪里出了问题吗 K = 4;N = 8; H1 = [0 0 0 1 1 0 1 1; 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 0 0 1 0 0 1 0 1]; H = sparse(H1); hEnc = comm.LDPCEncoder(H); hDec = comm

我生成一个奇偶校验矩阵,并使用comm.LDPCEncoder对码字进行编码。但是,当我使用comm.LDPCDecoder对LLR进行解码时,解码的字与源不同。 你能帮我找出哪里出了问题吗

K = 4;N = 8;
H1 =  [0 0 0 1 1 0 1 1;
    0 0 0 0 1 1 0 0
    1 1 0 0 0 0 0 1
    0 0 1 0 0 1 0 1];
H = sparse(H1);
hEnc = comm.LDPCEncoder(H);
hDec = comm.LDPCDecoder(H);
msg_source = logical(randi([0 1], K, 1));
msg_coded = step(hEnc, msg_source);  
LLR = double(msg_coded);
msg_decoded = step(hDec,LLR);
errors = (sum(xor(msg_source,msg_decoded)));

非常感谢。

它看起来像
LLR=double(msg\u编码)是问题的根源

我不是通信专家,从未使用过LDPC编码器和解码器。
我尝试了MATLAB代码示例,看到在调制和解调之后,
1
s(one)得到负值,
0
s(zero)得到正值

而不是
LLR=double(msg_编码)
您可以使用以下转换:
LLR=1-双精度(msg_编码)*2
0-->1

1-->-1

以下是修改后的代码:

K = 4;N = 8;
H1 =  [0 0 0 1 1 0 1 1;
    0 0 0 0 1 1 0 0
    1 1 0 0 0 0 0 1
    0 0 1 0 0 1 0 1];
H = sparse(H1);
hEnc = comm.LDPCEncoder(H);
hDec = comm.LDPCDecoder(H);
msg_source = logical(randi([0 1], K, 1));
msg_coded = step(hEnc, msg_source);  
%LLR = double(msg_coded);

%Convert from logical to double where 0 goes to -1 and 1 goes to 1.
LLR = 1 - double(msg_coded)*2;
msg_decoded = step(hDec,LLR);
errors = (sum(xor(msg_source,msg_decoded)));

下面是我用来查找问题的带有调制和解调的代码(基于MATLAB示例):


为什么要将逻辑编码数据转换为双精度数据?尝试在编码后立即解码:

K = 4;N = 8;
H1 =  [0 0 0 1 1 0 1 1;
    0 0 0 0 1 1 0 0
    1 1 0 0 0 0 0 1
    0 0 1 0 0 1 0 1];
H = sparse(H1);
hEnc = comm.LDPCEncoder(H);
hDec = comm.LDPCDecoder(H);
msg_source = logical(randi([0 1], K, 1));
msg_coded = step(hEnc, msg_source);  
msg_decoded = step(hDec,LLR);
errors = (sum(xor(msg_source,msg_decoded)));
K = 4;N = 8;
H1 =  [0 0 0 1 1 0 1 1;
    0 0 0 0 1 1 0 0
    1 1 0 0 0 0 0 1
    0 0 1 0 0 1 0 1];
H = sparse(H1);
hEnc = comm.LDPCEncoder(H);
hDec = comm.LDPCDecoder(H);
msg_source = logical(randi([0 1], K, 1));
msg_coded = step(hEnc, msg_source);  
msg_decoded = step(hDec,LLR);
errors = (sum(xor(msg_source,msg_decoded)));