本文记录一下BPSK的误比特率(BER)性能,并简单记录一下仿真程序
理论结果为
在此放上仿真的结果图
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% > 未编码BPSK传输BER性能
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ITR = 100000; % 重复次数
K = 100000; % 每次传输bit数
R = 1; % 码率
EbN0indB = -2:0.25:15; % Eb/N0 (dB)
EbN0=10.^(EbN0indB/10);
snr=EbN0*R ; % 信噪比
N0=1./snr;
sigma=sqrt(N0/2);
BER = zeros(length(sigma),1);
errorbits = zeros(length(sigma),1);
transbits = zeros(length(sigma),1);
MaxError = 1000;
for s=1:length(sigma)
for itr=1:ITR
msg = round(rand(K, 1)); % 生成bit
signal = 2*msg-1 + randn(K, 1)*sigma(s); % 加噪
recv = double(signal>0); % 硬判决
errorbits(s) = errorbits(s) + length(find(msg~=recv)); % 统计错误
transbits(s) = transbits(s) + K;
if errorbits(s)>MaxError % 错误足够则移到下一个EbN0点
break;
end
end
BER(s) = errorbits(s)/transbits(s);
% disp("EbN0="+EbN0indB(s)+", BER="+BER(s)) 显示临时结果
if errorbits(s)<MaxError % 错误不够多则停止再仿真下去
break;
end
end
plot(EbN0indB, BER)
hold on
Pb=0.5*erfc(sqrt(EbN0));
plot(EbN0indB, Pb)
set(gca,'YScale','log')
grid on
xlabel("E_bN_0(dB)")
ylabel("BER")
title("未编码BPSK传输BER性能")
参考文献:
【1】周炯槃 《通信原理(第三版)》