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

📄 qpsktest.asv

📁 实现QPSK和BPSK的调制解调程序
💻 ASV
字号:

%**************           程序说明            ***************************%
%%%%%%%%%%%%%%%% File: dqpsk.m%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% date: 2007-04-27  author: haige shengzhou corp. %%%%%%%%%%

%%% 目的:进行QDPSK调制的误码性能分析 %%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%变量名定义%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%nd:原是码元的个数;
%%%Origin_code_I:原始I路信号;
%%%Origin_code_Q:原始Q路信号;
%%%Transimit_code_I:码变换后I路信号;
%%%Transimit_code_Q:码变换后Q路信号;
%%%%receive_decode_I:接收端译码后I路信号;
%%%%receive_decode_Q:接收端译码后Q路信号;
%%%%%%%%%%%%%%%%程序主体%%%%%%%%%%%%%%%%%%%%%%%%%
sr=256000.0; % Symbol rate
ml=2;        % ml:Number of modulation levels (BPSK:ml=1, QPSK:ml=2, 16QAM:ml=4)
br=sr .* ml; % Bit rate
nd = 1000;   % Number of symbols that simulates in each loop
ebn0=1;      % Eb/N0
IPOINT=8;    % Number of oversamples

%************************* Filter initialization ***************************

irfn=21;                  % Number of taps
alfs=0.5;                 % Rolloff factor
[xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1);   %Transmitter filter coefficients 
[xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0);  %Receiver filter coefficients 

%******************** 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 ********************************  
	
    Origin_code_I=rand(1,nd)>0.5;  % 原始I路信号;
    Origin_code_Q=rand(1,nd)>0.5;  % 原始Q路信号;
    [Transimit_code_I,Transimit_code_Q]=qdpskmod(Origin_code_I,Origin_code_Q);%%原始信号编码
    	[ich1,qch1]= compoversamp(Transimit_code_I,Transimit_code_Q,length(Transimit_code_I),IPOINT); 
	[ich2,qch2]= compconv(ich1,qch1,xh); 
     
%**************************** Attenuation Calculation ***********************
	
    spow=sum(ich2.*ich2+qch2.*qch2)/nd;  % sum: built in function
	attn=0.5*spow*sr/br*10.^(-ebn0/10);
	attn=sqrt(attn);  % sqrt: built in function
     
%********************** Fading channel **********************

  % Generated data are fed into a fading simulator
  % [ifade,qfade]=sefade(ich2,qch2,itau,dlvl,th1,n0,itnd1,now1,length(ich2),tstp,fd,flat);
  
  % Updata fading counter
  %itnd1 = itnd1+ itnd0;

%********************* Add White Gaussian Noise (AWGN) **********************
	
    [ich3,qch3]= comb(ich2,qch2,attn);% add white gaussian noise
	[ich4,qch4]= compconv(ich3,qch3,xh2);
    

    syncpoint=irfn*IPOINT+1;
    ich5=ich4(syncpoint:IPOINT:length(ich4));
    qch5=qch4(syncpoint:IPOINT:length(qch4));
        
%**************************** QPSK Demodulation *****************************

    [ich6,qch6]=qpskdemod1(ich5,qch5,1,nd,ml);
    ich7=2*ich6-1;
    qch7=2*qch7-1;
    noe=sum(abs(ich7-Transimit_code_I))+sum(abs(qch7-Transimit_code_I))
    
    
    [Transimit_code_I1,Transimit_code_Q1]= compoversamp(Transimit_code_I,Transimit_code_Q,length(Transimit_code_I),IPOINT); 
	[Transimit_code_I2,Transimit_code_Q2]= compconv(Transimit_code_I1,Transimit_code_Q1,xh);
    spow=sum(Transimit_code_I2.*Transimit_code_I2+Transimit_code_Q2.*Transimit_code_Q2)/nd;  % sum: built in function
	attn=0.5*spow*sr/br*10.^(-ebn0/10);
	attn=sqrt(attn);  % sqrt: built in function
    
    [Transimit_code_I3,Transimit_code_Q3]= comb(Transimit_code_I2,Transimit_code_Q2,attn);% add white gaussian noise
	[Transimit_code_I4,Transimit_code_Q4]= compconv(Transimit_code_I3,Transimit_code_Q3,xh2);
    
     syncpoint=irfn*IPOINT+1;
    Transimit_code_I5=Transimit_code_I4(syncpoint:IPOINT:length(Transimit_code_I3));
    Transimit_code_Q5=Transimit_code_Q4(syncpoint:IPOINT:length(Transimit_code_Q3));
%     figure(2)
%     subplot(2,1,1);
%     plot(Transimit_code_I);
%      subplot(2,1,2);
%     plot(Transimit_code_I5);
       
    
    
    Transimit_code_I6=Transimit_code_I5>=0;
    Transimit_code_Q6=Transimit_code_Q5>=0;
    [receive_decode_I,receive_decode_Q]=dpskdemod(Transimit_code_I6,Transimit_code_Q6);%译码
%     figure(1)
%     subplot(2,1,1);
%     plot(Origin_code_I);
%      subplot(2,1,2);
%     plot(receive_decode_I);
%      figure(2)
%     subplot(2,1,1);
%     plot(Transimit_code_I);
%      subplot(2,1,2);
%     plot(Transimit_code_I5);
%        
%       figure(3)
%     subplot(2,1,1);
%     plot(Transimit_code_Q);
%      subplot(2,1,2);
%     plot(Transimit_code_Q5);
%************************** Bit Error Rate (BER) ****************************
Transimit_code_I6=2*Transimit_code_I6-1;
Transimit_code_Q6=2*Transimit_code_Q6-1;
    noe1=sum(abs(Transimit_code_I6-Transimit_code_I))+sum(abs(Transimit_code_Q6-Transimit_code_Q));

    noe2=sum(abs(receive_decode_I-Origin_code_I))+sum(abs(receive_decode_Q-Origin_code_Q));  % sum: built in function
	nod2=length(Origin_code_I)+length(Origin_code_Q);  % length: built in function
	noe=noe+noe2;
	nod=nod+nod2;

end % for iii=1:nloop    

%********************** Output result ***************************

ber = noe/nod;

⌨️ 快捷键说明

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