⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bpsk_golay.m

📁 以bpsk为平台的golay编码解码功能,及其误码曲线分析
💻 M
字号:
% bpsk.m
%******************** Preparation part **********************
sr=1000.0; % Symbol rate
ml=1;        % Number of modulation levels
br=sr.*ml;   % Bit rate (=symbol rate in this case)
nd = 12;   % Number of symbols that simulates in each loop
IPOINT=8;    % Number of oversamples
%********************* Filter initialization **********************
irfn=21;     % Number of filter taps          
alfs=0.5;    % Rolloff factor
[xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1);   
[xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0);  
%******************** START CALCULATION **************************
nloop=60000;  % Number of simulation loops
ebn0=1:10;
ber=zeros(1,10);
for ii=1:10
    noe = 0;    % Number of error data
    nod = 0;    % Number of transmitted data
    for iii=1:nloop  
%******************** Data generation **********************************  
	    data=rand(1,nd)>0.5;  % rand: built in function
%********************* Golay encode ***********************************
     
         data0=golayencode(data);  %data0:   24bit

%*********************** BPSK Modulation *******************************  
         data1=data0.*2-1;
	     [data2] = oversamp1(data1,nd ,IPOINT) ;
	     data3 = conv(data2,xh);  % conv: built in function
%******************** Attenuation Calculation *************************
         spow=sum(data3.*data3)/nd;
	      attn=0.5*spow*sr/br*10.^(-ebn0(ii)/10);
	     attn=sqrt(attn);
 %*************** Add White Gaussian Noise (AWGN) ***********************
	     inoise=randn(1,length(data3)).*attn*0.8;  % randn: built in function
	     data4=data3+inoise;
	     data5=conv(data4,xh2);  % conv: built in function
	     sampl=irfn*IPOINT+1;
	     data6 = data5(sampl:8:8*nd+sampl-1+12*8);
%******************** BPSK Demodulation *********************
         demodata1=data6 > 0;
%********************* Golay decode *****************************
    
         demodata=golaydecode(demodata1);
    
%******************** Bit Error Rate (BER) ******************
         demodata2=demodata(1:12);
         noe2=sum(abs(data-demodata2));  % sum: built in function
	     nod2=length(data);  % length: built in function
	     noe=noe+noe2;
	    nod=nod+nod2;
	 end % for iii=1:nloop    
%********************** Output result ***************************
    ber(ii) = noe/nod;
end
hold on
plot(ebn0,ber,'b*');
%******************** end of file ***************************
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -