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

📄 qam.m

📁 16QAM的调制解调程序
💻 M
字号:
% 16QAM Modualtion

% Intialization
Ld=4096;
OSF=4;
SNR_dB=20;

load('RRC_4.mat');
PSF_Len=length(RRC_4);
% RRC_4=[];
% QPSK_Constellation=1/sqrt(2)*[1+j, -1+j,  1-j,-1-j];

% Source data
d=randint(1,Ld,2);                                                      
% 16QAM Modulation
%Mod=(1-2*d(1:2:end)+j*(1-2*d(2:2:end)))/sqrt(2);
Mod=((2*d(1:4:end)-1)*2+j*(2*d(2:4:end)-1)*2+2*d(3:4:end)-1+j*(2*d(4:4:end)-1))/sqrt(10);
% Upsample
Mod_Upsample=reshape([Mod;zeros(OSF-1,Ld/4)],1,OSF*Ld/4);
% TX pulse shaping filter  (Power normalization)
s=conv(OSF*Mod_Upsample,RRC_4);
% Select
tx=s((PSF_Len-1)/2+1:end-(PSF_Len-1)/2);
% AWGN Channel
rx=awgn(tx,SNR_dB-10*log10(OSF),'measured');
% RX matched filter (pulse shaping filter)
rx_filter=conv(rx,RRC_4);
% Select (sychronization)
rx_decision=rx_filter((PSF_Len-1)/2+1:end-(PSF_Len-1)/2);
% downsample
Mod_downsample=rx_decision(1:OSF:end);
% Hard decision
re=real(Mod_downsample);
im=imag(Mod_downsample);
for wy=1:Ld/4
   if re(wy)>0.632 
       d1(wy)=1;
       d3(wy)=1;
     elseif re(wy)>0   
         d1(wy)=1;
         d3(wy)=0;
     elseif re(wy)>-0.632   
         d1(wy)=0;
         d3(wy)=1;
     else d1(wy)=0;
          d3(wy)=0;
   end
   if im(wy)>0.632 
       d2(wy)=1;
       d4(wy)=1;
     elseif im(wy)>0   
         d2(wy)=1;
         d4(wy)=0;
     elseif im(wy)>-0.632   
         d2(wy)=0;
         d4(wy)=1;
     else d2(wy)=0;
          d4(wy)=0;
   end
end
%output data
dd=reshape([d1;d2;d3;d4],1,Ld);
%test error rate
test=dd-d;
count=0;
for i=1:4096
    if test(i)~=0  count=count+1;
    end
end
BER=count/Ld

⌨️ 快捷键说明

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