matlab - 误码率计算 15,11 汉明码图
问题描述
下面,在我的代码中是假设找到模拟 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 = bitrr(dataIn,dataDec2)] 上使用断点调试了您的代码。看起来 dataIn 数组是 100 x 1 并且 dataDec2 是 110 x 1 数组。'biterr' 函数计算长度相等的两个向量不同的位置数。
这会给你一个更好的解释。 https://www.mathworks.com/help/comm/ref/biterr.html
推荐阅读
- java - 为什么我的 Java Appium 测试在本地工作,但在 Browserstack 上运行时却很糟糕?
- node.js - 创建意图后未检测到操作和参数
- oracle - 授予 Oracle 中其他用户的表传递
- python - 根据多个日期条件选择和计算行的最快方法是什么?
- c# - 发现歧义调用时如何指定调用哪个扩展方法
- excel - 当且仅当值相同时,如何循环删除工作表?
- azure - Call azure ad-protected API from powershell with username/password
- javascript - 放慢跳转到divi主题中的锚点
- python-2.7 - QPython 请求 SSL 错误 - 没有可用的密码
- c++ - 我使用 C++ 调用 LSCopyApplicationURLsForURL(),但出现段错误