www.pudn.com > 04041115_2_bpsk.zip > bpsk.m


%bpsk.m 
%simulation program to realize BPSK transmition system(under one path 
%fading) 
%*********************preparation part ****************************** 
sr=256000.0; 
m1=1; 
br=sr.*m1; 
nd=100; 
ebn0=10; 
IPOINT=8; 
%***********************filter initia;ization ************************** 
irfn=21; 
alfs=0.5; 
[xh]=hrollfcoef(irfn,IPOINT,sr,alfs,1); 
[xh2]=hrollfcoef(irfn,IPOINT,sr,alfs,0); 
%*************************fading initialization************************** 
tstp=1/sr/IPOINT; 
itau=[0]; 
dlvl=[0]; 
n0=[6]; 
th1=[0.0]; 
itnd0=nd*IPOINT*100; 
itnd1=[1000]; 
now1=1; 
fd=160; 
flat=1; 
%*************************start calculation ***************************** 
%nloop=1000; 
%noe=0; 
%nod=0; 
%for iii=1:nloop 
%**************************data generation ******************************* 
data=rand(1,nd)>0.5 
%***************************bpsk modulation ****************************** 
data1=data.*2-1; 
[data2]=oversamp(data1,nd,IPOINT); 
data3=conv(data2,xh); 
%***************************attenuation calculation ********************** 
spow=sum(data3.*data3)/nd; 
attn=0.5*spow*sr/br*10.^(-ebn0/10); 
attn=sqrt(attn); 
%***************************fading channel******************************* 
%[ifade,qfade]=sefade(data3,zeros(1,length(data3)),itau,dlvl,th1,n0,itnd1,now1,length(data3),tstp,fd,flat); 
%itnd1=itnd1+itnd0; 
%**************************AWGN****************************************** 
inoise=randn(1,length(data3)).*attn; 
data4=data3+inoise; 
data5=conv(data4,xh2); 
samp1=irfn*IPOINT+1; 
data6=data5(samp1:8:8*nd+samp1-1); 
%***************************bpsk demodulation**************************** 
demodata=data6>0 
%**************************bit error data******************************* 
%noe2=sum(abs(data-demodata)); 
%nod2=length(data); 
%noe=noe+noe2; 
%nod=nod+nod2; 
%fprintf('%d\t%e\n',iii,noe2/nod2); 
%end %for iii=1:nloop 
%***************************output result ***************************** 
%ber=noe/nod; 
%fprintf('%d\t%d\t%d\t%e\n',ebn0,noe,nod,noe/nod); 
%fid=fopen('berbpskfad.dat','a'); 
%fprintf(fid,'%d\t%e\t%f\t%f\t\n',ebn0,noe/nod,noe,nod); 
%fclose(fid); 
%*****************************end of file******************************