附录
附文中所用仿真程序:
图3.1如下
% bpsk.m
% Simulation program to realize BPSK transmission system
%******************** Preparation part ********************** nd = 10000; % Number of symbols that simulates in each loop snr_in_dB=[0:15] ;
ber=zeros(1,length(snr_in_dB));
for snr_num=1:length(snr_in_dB)
SNR=exp(snr_in_dB(snr_num)*log(10)/10);
%******************** START CALCULATION ********************* nloop=100; % Number of simulation loops noe = 0; % Number of error data
nod = 0; % Number of transmitted data
for iii=1:nloop
%******************** Data generation ********************************
data1=rand(1,nd)>0.5; data2=2.*data1-1;
%****************** Attenuation Calculation ***************** %****************** rayleigh channel *****************
code_rate=1; E=1;
sigma=E/sqrt(2*SNR*code_rate); n =[randn(1,nd) + j*randn(1,nd)];
h1 =1/sqrt(2)*[randn(1,nd) + j*randn(1,nd)]; % Rayleigh channel data41=data2.*h1+sigma.*n;
h11=conj(h1)./abs(h1); %注释: data411 = data41.*h11; %注释:
%***************************************** n =[randn(1,nd) + j*randn(1,nd)];
h2 =1/sqrt(2)*[randn(1,nd) + j*randn(1,nd)]; % Rayleigh channel data42=data2.*h2+sigma.*n; h22=conj(h2)./abs(h2); data422 =data42.*h22;
%***************************************** data4=data411+data422; %注释:
%******************** BPSK Demodulation *********************
demodata1=data4 > 0;
%******************** Bit Error Rate (BER) ******************
noe2=sum(abs(data1-demodata1)); nod2=length(data1); noe=noe+noe2; nod=nod+nod2;
end
%********************** Output result ***************************
ber1(snr_num) = noe/nod
end;
%******************** end of file *************************** figure;
semilogy(snr_in_dB,ber1,'O-'); hold on
semilogy(snr_in_dB,0.5*erfc(sqrt(2*10.^(snr_in_dB/10))/sqrt(2)),'+-'); hold on
semilogy(snr_in_dB,0.5.*(1-sqrt((10.^(snr_in_dB/10))./(10.^(snr_in_dB/10)+1))),'-');
ylabel('BER');
xlabel('E_b/N_0 [dB]'); legend('simulation BPSK EGC L=2','theory gngauss BPSK','theory reyleigh' ); grid on;
图3.2如下:
% bpsk.m
% Simulation program to realize BPSK transmission system
%******************** Preparation part ********************** nd = 10000; % Number of symbols that simulates in each loop snr_in_dB=[0:15] ;
ber=zeros(1,length(snr_in_dB));
for snr_num=1:length(snr_in_dB)
SNR=exp(snr_in_dB(snr_num)*log(10)/10);
%******************** START CALCULATION ********************* nloop=100; % Number of simulation loops noe = 0; % Number of error data
nod = 0; % Number of transmitted data
for iii=1:nloop
%******************** Data generation ********************************
data1=rand(1,nd)>0.5; data2=2.*data1-1;
%****************** Attenuation Calculation ***************** %****************** rayleigh channel *****************
code_rate=1; E=1;
sigma=E/sqrt(2*SNR*code_rate); n =[randn(1,nd) + j*randn(1,nd)];
h1 =1/sqrt(2)*[randn(1,nd) + j*randn(1,nd)]; % Rayleigh channel data41=data2.*h1+sigma.*n; h11=conj(h1); %注释:
data411 = data41.*h11; %注释:
%***************************************** n =[randn(1,nd) + j*randn(1,nd)];
h2 =1/sqrt(2)*[randn(1,nd) + j*randn(1,nd)]; % Rayleigh channel data42=data2.*h2+sigma.*n; h22=conj(h2);
data422 =data42.*h22;
%***************************************** data4=data411+data422;% 注释:
%******************** BPSK Demodulation *********************
demodata1=data4 > 0;
%******************** Bit Error Rate (BER) ******************
noe2=sum(abs(data1-demodata1)); nod2=length(data1); noe=noe+noe2;

