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

📄 qam16_basic.m

📁 上传的是一个16Qam预失真处理的程序
💻 M
字号:

% qam16_basic.m
%
% Simulate basic 16 QAM with AWGN
%
% Programmed by linxiaochen  

%******************** Preparatin part *******************************

sr = 256000.0;                 % Symbol rate
m1 = 4;                        % m1:Number of modulation levels
                               % (BPSK:m1=1, QPSK:m1=2, 16QAM:m1=4)
br = sr .* m1;                 % Bit rate
nd = 2^10;                     % Number of symbols htat simulates in
                               % each loop
IPOINT = 8;                    % Number of oversamples

SNR_dB = 1:12;                           % 仿真信噪比范围
SNR1_dB = 0:0.1:12;  

%******************** 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
 
%******************** Data generation *******************************
     
      data1 = rand(1,nd*m1) > 0.5;    % rand:built in function

%******************** 16QAM Modulation ******************************

     [ich,qch] = qammod(data1,1,nd,m1);
     figure(1);
     plot(ich,qch,'*');
     QAM_mod = ich + i*qch;
      [ich1,qch1] = compoversamp(ich,qch,length(ich),IPOINT);
      [ich2,qch2] = compconv(ich1,qch1,xh);
      
for ebn0 = 1:12
     
%******************** START CALCULATION *****************************

nloop = 10;                       % Number of simulation loops
noe = 0;                           % Number of error data
nod = 0;                           % Number of transmitted data

   for iii = 1:nloop     
%******************** Attenuation Calculation ***********************

      spow = sum(ich2.*ich2+qch2.*qch2)/nd;
          % sum:built in function
      attn = 0.5*spow*sr/br*10.^(-(ebn0-1)/10);
      attn = sqrt(attn);
          % sqrt:built in function
     
%************** Add White Gaussian Noise (AWGN) *********************

     [ich3,qch3] = comb(ich2,qch2,attn);
          % add white gaussian noise
     [ich4,qch4] = compconv(ich3,qch3,xh2);
      
     sampl = irfn*IPOINT+1;
     ich5 = ich4(sampl:IPOINT:length(ich4));
     qch5 = qch4(sampl:IPOINT:length(qch4));
      
     ich6 = ich5(1:1000);
     qch6 = qch5(1:1000);
     figure(2);
     plot(ich6,qch6,'*');
     QAM_demod = ich5 + i*qch5;
    
%******************** 16QAM Demodulation ****************************
     
     [demodata] = qamdemod(ich5,qch5,1,nd,m1);
      
%******************** Bit Error Rate (BER) **************************
  
     noe2 = sum(abs(data1-demodata));
     nod2 = length(data1);
     noe = noe + noe2;
     nod = nod + nod2;
     
     ber(ebn0) = noe/nod;
  
end  % for iii = 1:nloop

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

t1 = [0:0.1:12];
tt1=exp(t1*log(10)/10);  
B1 = 3/8.*erfc(sqrt(2/5.*tt1))-9/64.*erfc(sqrt(2/5.*tt1)).*erfc(sqrt(2/5.*tt1));
t11=[0:(length(ber)-1)];
figure(3);
semilogy(t1,B1,t11,ber,'*');

% %******************** end of file ***********************************

⌨️ 快捷键说明

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