www.pudn.com > BPSKerr_rate.rar > BPSKerr_rate.m, change:2007-05-29,size:854b


function BPSKerr_rate=berplot 
close all; 
clear all; 
clc 
 
SNRindb=-10:40; 
for i=1:length(SNRindb) 
smerr_prb(i)=BPSK(SNRindb(i));  
 
end 
 
semilogy(SNRindb,smerr_prb); 
xlabel('SNR(dB)'); 
ylabel('BER'); 
legend(' simulated result'); 
 
%Ӻ 
function[p]=BPSK(SNRdb) 
 
N=5000; 
E=1;  
SNR=10^(SNRdb/10);  
sgma=E/sqrt(SNR);  
for i=1:N 
a=rand; 
if(a<0.5) 
trans(i)=-1; 
else 
trans(i)=1; 
end 
end 
 
numofber=0; 
totolnumber=0; 
while numofber<1 
totolnumber=totolnumber+1; 
for i=1:N 
H1=normrnd(0,sqrt(0.5))+j*normrnd(0,sqrt(0.5)); 
H2=normrnd(0,sqrt(0.5))+j*normrnd(0,sqrt(0.5)); 
H=[H1;H2]; 
y1=H(1)*trans(i)+(normrnd(0,sgma)+j*normrnd(0,sgma)); 
y2=H(2)*trans(i)+(normrnd(0,sgma)+j*normrnd(0,sgma)); 
y=[y1;y2]; 
s=H'*y; 
decis=sign(real(s)); 
if (decis~=trans(i)) 
numofber=numofber+1; 
 
end 
 
end 
end 
p=numofber/(N*totolnumber);