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

📄 sq16qam_gray_map.m

📁 一些关于调指和解调的小程序
💻 M
字号:
function out=sq16QAM_Gray_map(input)

%%%--------example---------------------
%%% input=[0 0 0 1 0 1 1 1 1 0 0 1]
%%% out=[1+3j
%%%     -1+j
%%%     1-3j]


%%%将输入的信息比特流映射为方形16QAM星座点;输出为并行复数序列,为表示星座点的复数
%%%输入序列长度应为4的倍数;每4个比特映射为一个星座点

%%% 'input' is the inputed source bit sequence
%%% 'output' is the mapped constellations, and is still a serial sequence

K=length(input)/4;    %%% The number of symbols
d=1/sqrt(10);                  %%% The minimum distance between constellations is 2*d
x=[3*d,d,-d,-3*d];    %%% coordinate matrix
y=[3*d,d,-d,-3*d];

for i=1:K             %%%将input变成K×4的矩阵,便于映射处理,每一行对应一个星座点
    for k=1:4
        temp(i,k)=input(4*(i-1)+k);
    end
end

%%% mapping --------------------------------
%%% Y-coordinate ---------------------------%%% 4个比特中的前两位决定纵坐标,后两位决定横坐标
for i=1:K
    if [temp(i,1),temp(i,2)]==[0,0]
        max(i,2)=y(1);
        
    end
    
    if [temp(i,1),temp(i,2)]==[0,1]
        max(i,2)=y(2);
      
    end
    
    if [temp(i,1),temp(i,2)]==[1,1]
        max(i,2)=y(3);
   
    end
    
    if [temp(i,1),temp(i,2)]==[1,0]
        max(i,2)=y(4);
   
    end
end

%%% X-coordinate --------------------------
for i=1:K
     if [temp(i,3),temp(i,4)]==[0,0]
        max(i,1)=x(1);
 
    end
    
    if [temp(i,3),temp(i,4)]==[0,1]
        max(i,1)=x(2);
       
    end
    
    if [temp(i,3),temp(i,4)]==[1,1]
        max(i,1)=x(3);
    
    end
    
    if [temp(i,3),temp(i,4)]==[1,0]
        max(i,1)=x(4);
    
    end
end


clear i;
clear k;
clear temp;

%%% j=sqrt(-1);  %%%% if you have use j as a variable,then you must have to define j as a complex 
                 %%%%  if you want to use it as a complex sign

for i=1:K
    p_out(i,:)=max(i,1)+max(i,2)*j;   %%% generate complex constellations,and serial sequence
end
clear max;

out=p_out;     %%% parallel complex constellations sequence


⌨️ 快捷键说明

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