【问题标题】:bit error rate calculation 15,11 hamming code graph误码率计算 15,11 汉明码图
【发布时间】:2018-10-18 08:23:39
【问题描述】:

下面,在我的代码中是假设找到模拟 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);

【问题讨论】:

  • 其他用户将您的问题标记为低质量和需要改进。我重新措辞/格式化您的输入,使其更易于阅读/理解。请查看我的更改以确保它们反映您的意图。如果您对我有其他问题或反馈,请随时给我留言。

标签: matlab hamming-code ber


【解决方案1】:

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

这会给你一个更好的解释。 https://www.mathworks.com/help/comm/ref/biterr.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-05
    • 2012-10-23
    • 2012-05-29
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2019-04-23
    相关资源
    最近更新 更多