繁体   English   中英

误码率15,11汉明码图

[英]bit error rate calculation 15,11 hamming code graph

下面,我的代码中是假设找到模拟BER。 但是我在此代码上遇到错误,其中nErrors = biterr(dataIn,dataDec2)此行给出矩阵尺寸不匹配。

有谁可以帮助我吗?

close all;
clear all;

M = 2;                 % Modulation order
k = log2(M);            % Bits per symbol
EbNoVec = -4:2:0;      % Eb/No values (dB)
No = -10;
numSymPerFrame = 100;   % Number of PSK symbols per frame
berEst2 = zeros(size(EbNoVec));
G2=[1 1 0 0 1 0 0 0 0 0 0 0 0 0 0; 
0 1 1 0 0 1 0 0 0 0 0 0 0 0 0; 
0 0 1 1 0 0 1 0 0 0 0 0 0 0 0; 
1 0 1 0 0 0 0 1 0 0 0 0 0 0 0;
1 0 0 1 0 0 0 0 1 0 0 0 0 0 0;
0 1 0 1 0 0 0 0 0 1 0 0 0 0 0;
1 1 1 0 0 0 0 0 0 0 1 0 0 0 0;
0 1 1 1 0 0 0 0 0 0 0 1 0 0 0;
1 0 1 1 0 0 0 0 0 0 0 0 1 0 0;
1 1 0 1 0 0 0 0 0 0 0 0 0 1 0;
1 1 1 1 0 0 0 0 0 0 0 0 0 0 1   ];
H2= gen2par(G2);
decoding2 = syndtable(H2); 
Pt2 = zeros(size(EbNoVec));
for n = 1:length(EbNoVec)
% Convert Eb/No to SNR
snrdB = EbNoVec(n) + 10*log10(15/11);
% Reset the error and bit counters
numErrs = 0;
numBits = 0;
Pt2(n)= 10^((snrdB-10)/10);
while numErrs < 100
    % Generate binary data and convert to symbols
    dataIn = randi([0 1],numSymPerFrame,k)
    dataSym = bi2de(dataIn)
    dataEnc2 = encode(dataIn,15,11,'linear/binary',G2)
    % PSK modulation

    txSig = pskmod(dataEnc2,M);

    % Pass through AWGN channel
    rxSig = awgn(txSig,snrdB,'measured');

    % Demodulate the noisy signal
    rxSym = pskdemod(rxSig,M);
    % Convert received symbols to bits
    dataOut = de2bi(rxSym,k);
    dataDec2 =decode(rxSym,15,11,'linear/binary',G2, decoding2);
    % Calculate the number of bit errors
    nErrors = biterr(dataIn,dataDec2);

    % Increment the error and bit counters
    numErrs = numErrs + nErrors;
    numBits = numBits + numSymPerFrame*k;
end

% Estimate the BER
berEst2(n) = numErrs/numBits;


end
berTheory2 = berawgn(EbNoVec,'psk',M,'nondiff');
hold on 
semilogy(EbNoVec,berEst1,'r','LineWidth',2);

我在第46行[nErrors = biterr(dataIn,dataDec2)]上使用断点调试了您的代码。 似乎dataIn数组是100 x 1,dataDec2是110 x 1数组。 'biterr'函数计算长度相等的两个向量不同的位置数。

这将为您提供更好的解释。 https://www.mathworks.com/help/comm/ref/biterr.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM