首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >误码率计算15,11汉明码图

误码率计算15,11汉明码图
EN

Stack Overflow用户
提问于 2018-10-18 16:23:39
回答 1查看 750关注 0票数 0

下面,在我的代码中假设找到了模拟误码率。但我在这段代码中遇到了错误,nErrors = biterr(dataIn,dataDec2)这一行给出了矩阵尺寸不匹配的结果。

有人能在这方面帮我吗??

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2018-10-20 06:21:52

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

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52869873

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档