概述
1.问题描述:
4PAM的误码率仿真
2.部分程序:
%BER of 4PAM
clear all;clc;
Nb=10000; %the number of data bits
EbN0dB=1:30; %Eb/N0 in dB
EbN0 = 10.^(EbN0dB/10);
Nerr=zeros(1,length(EbN0)); % initialize Nerr vector
for k=1:length(EbN0)
b=rand(1,Nb)>0.5; % 0 or 1 random data
b2 = reshape(b,2,[])';
for i = 1:length(b2)
x(1,i) = (2*b2(i,1) -1) * (2*(b2(i,2)==0)+1); %4PAM mapping
end
Eb=1; % bit energy
N0=Eb/EbN0(k); % noise PSD (W/Hz)
varn=N0/2; % noise variance
noise=sqrt(varn)*randn(1,Nb/2); % AWGN ~ N(0,varn)
r=x+noise; % received signal
%4PAM demapping
for i = 1:length(r)
d2(1,i) = r(1,i)>0;
d2(2,i) = abs(r(1,i)) < 2;
end
d = reshape(d2,1,[]);
Nerr(k)=sum(b~=d); % the number of error bits
end
ber=Nerr/Nb; % bit error rate by simulation
EbN0dB2=0:0.01:10;
EbN02=10.^(EbN0dB2/10);
ber2=Q(sqrt(2*EbN02)); % bit error rate by theory
figure;
semilogy(EbN0dB,ber,'s'); hold on;
semilogy(EbN0dB2,ber2);
xlabel('E_b/N_0'); ylabel('BER'); grid on;
legend('Simulation', 'Theory');
3.仿真结论:
D103
最后
以上就是跳跃草丛为你收集整理的4PAM的误码率仿真的全部内容,希望文章能够帮你解决4PAM的误码率仿真所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复