# 基于4PAM调制性能误码率仿真源码程序

### 时间：2017-5-11 22:07:30 点击：

核心提示：基于4PAM调制性能误码率仿真源码程序...
matlab代做|matlab专业代做|matlab淘宝代做
QQ: 1224848052

%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)
%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');

• 百度搜索