qam64encode_new.m

来自「由4个.m文件组成」· M 代码 · 共 36 行

M
36
字号
%64QAM modulation mapping
%N is the number of output symbol
%qam_sig is the output complex QAM signal vector
%the power of qam_sig is normalized to 1 per symbol.
%qam_bit is the output 6-bit vector
function [qam_sig]=QAM64encode_new(encod2)
N=length(encod2);
lrem=rem(N,6);
if lrem~=0
   encod2(N+1:N+(6-lrem))=0;
end
NN=length(encod2);
   
d=sqrt(40/40);%to normalize the energy of the QAM symbol
%d=1;

ConsI=[-7*d -5*d -3*d -d d d*3 5*d 7*d];
ConsQ=[-7*d -5*d -3*d -d d d*3 5*d 7*d];
        
I=[0 0 0;0 0 1;0 1 1;0 1 0;1 1 0;1 1 1;1 0 1;1 0 0];
Q=[0 0 0;0 0 1;0 1 1;0 1 0;1 1 0;1 1 1;1 0 1;1 0 0];

for i1=0:6:NN-1,
   % encode bit map 
   nu1=[encod2(i1+1) encod2(i1+2) encod2(i1+3)];
   nu2=[encod2(i1+4) encod2(i1+5) encod2(i1+6)];

   for j=1:8
      eu1(j)=(nu1-I(j,:))*(nu1-I(j,:))';
      eu2(j)=(nu2-Q(j,:))*(nu2-Q(j,:))';
   end
   [mineu1,index1]=min(eu1);
   [mineu2,index2]=min(eu2);
 
   qam_sig(i1/6+1)=ConsI(index1)+i*ConsQ(index2);
   end;

⌨️ 快捷键说明

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