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

📄 sq32qam_gray_map2.m

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

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

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

%%%--------Gray mapping----------------------
for i=1:K
    
    %%%------------first filed--------------------------
    if temp(i,1:2)==[0,0]           
        if temp(i,3:5)==[0,0,0]
            t_out(i,:)=d*[1,5];
        end
        if temp(i,3:5)==[0,0,1]
            t_out(i,:)=d*[1,3];
        end
        if temp(i,3:5)==[0,1,1]
            t_out(i,:)=d*[1,1];
        end
        if temp(i,3:5)==[1,1,1]
            t_out(i,:)=d*[3,1];
        end
        if temp(i,3:5)==[1,0,1]
            t_out(i,:)=d*[5,1];
        end
        if temp(i,3:5)==[1,0,0]
            t_out(i,:)=d*[5,3];
        end
        if temp(i,3:5)==[1,1,0]      %%% This point coordinate is defferent from that of the other mapping method
            %%t_out(i,:)=d*[5,5];
            t_out(i,:)=d*[3,3];
        end
        if temp(i,3:5)==[0,1,0]
            t_out(i,:)=d*[3,5];
        end
    end
    
    %%%---------second field-------------------
    if temp(i,1:2)==[0,1]           
        if temp(i,3:5)==[0,0,0]
            t_out(i,:)=d*[-1,5];
        end
        if temp(i,3:5)==[0,0,1]
            t_out(i,:)=d*[-1,3];
        end
        if temp(i,3:5)==[0,1,1]
            t_out(i,:)=d*[-1,1];
        end
        if temp(i,3:5)==[1,1,1]
            t_out(i,:)=d*[-3,1];
        end
        if temp(i,3:5)==[1,0,1]
            t_out(i,:)=d*[-5,1];
        end
        if temp(i,3:5)==[1,0,0]
            t_out(i,:)=d*[-5,3];
        end
        if temp(i,3:5)==[1,1,0]
            %%t_out(i,:)=d*[-5,5];
            t_out(i,:)=d*[-3,3]    
        end
        if temp(i,3:5)==[0,1,0]
            t_out(i,:)=d*[-3,5];
        end
    end
    
    %%%--------third field--------------------------
    if temp(i,1:2)==[1,1]           
        if temp(i,3:5)==[0,0,0]
            t_out(i,:)=d*[-1,-5];
        end
        if temp(i,3:5)==[0,0,1]
            t_out(i,:)=d*[-1,-3];
        end
        if temp(i,3:5)==[0,1,1]
            t_out(i,:)=d*[-1,-1];
        end
        if temp(i,3:5)==[1,1,1]
            t_out(i,:)=d*[-3,-1];
        end
        if temp(i,3:5)==[1,0,1]
            t_out(i,:)=d*[-5,-1];
        end
        if temp(i,3:5)==[1,0,0]
            t_out(i,:)=d*[-5,-3];
        end
        if temp(i,3:5)==[1,1,0]
            %%t_out(i,:)=d*[-5,-5];
            t_out(i,:)=d*[-3,-3]
        end
        if temp(i,3:5)==[0,1,0]
            t_out(i,:)=d*[-3,-5];
        end
    end
    
    %%%----------forth filed-------------------- 
    if temp(i,1:2)==[1,0]           
        if temp(i,3:5)==[0,0,0]
            t_out(i,:)=d*[1,-5];
        end
        if temp(i,3:5)==[0,0,1]
            t_out(i,:)=d*[1,-3];
        end
        if temp(i,3:5)==[0,1,1]
            t_out(i,:)=d*[1,-1];
        end
        if temp(i,3:5)==[1,1,1]
            t_out(i,:)=d*[3,-1];
        end
        if temp(i,3:5)==[1,0,1]
            t_out(i,:)=d*[5,-1];
        end
        if temp(i,3:5)==[1,0,0]
            t_out(i,:)=d*[5,-3];
        end
        if temp(i,3:5)==[1,1,0]
            %%t_out(i,:)=d*[5,-5];
            t_out(i,:)=d*[3,-3]
        end
        if temp(i,3:5)==[0,1,0]
            t_out(i,:)=d*[3,-5];
        end
    end
end

for i=1:K
    out(i,:)=t_out(i,1)+j*t_out(i,2);   %%% parallel sequence
end

clear K d x y temp t_out

⌨️ 快捷键说明

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