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

📄 sq64qam_gray_demap.m

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

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


%%% This function have the only function of demapping
%%% 'input' is complex sequence from channel and FFT transformer, and is parallel sequence( K×1 matrix)
%%% 'out' is serial binary bit sequence
%%% The course of demapping use the criterion of Minimum Euclidean Distance(MED)

K=length(input);
d=1/sqrt(42);                  %%% The minimum distance between constellations is 2*d

x=[7*d,5*d,3*d,d,-d,-3*d,-5*d,-7*d];    %%% coordinate matrix
y=[7*d,5*d,3*d,d,-d,-3*d,-5*d,-7*d]; 


for i=1:K
    temp(i,:)=[real(input(i)),imag(input(i))];      %%% 复数矩阵变成实数矩阵,便于处理
end


%%% 解调采用比较横纵坐标,找最接近的横纵坐标的方法,相当于量化的思想
%%% X-coordinate demapping -----------------------------------------------
for i=1:K
    for k=1:8                %%% 先比较横坐标
        dis(k)=temp(i,1)-x(k);
    end
    [di,num]=min(abs(dis));  %%% 坐标距离最短
    temp(i,1)=x(num);        %%% 横坐标解调出来,并保存到原来矩阵中
   
    
    if x(num)==x(1)
        t_out(i,4:6)=[0,0,0];   %%% 横坐标决定6个比特中的后三位
    end
    
    if x(num)==x(2)
        t_out(i,4:6)=[0,0,1];
    end
    
    if x(num)==x(3)
        t_out(i,4:6)=[0,1,1];
    end
    
    if x(num)==x(4)
        t_out(i,4:6)=[0,1,0];
    end
    
    if x(num)==x(5)
        t_out(i,4:6)=[1,1,0];
    end
    
    if x(num)==x(6)
        t_out(i,4:6)=[1,1,1];
    end
    
    if x(num)==x(7)
        t_out(i,4:6)=[1,0,1];
    end
    
    if x(num)==x(8)
        t_out(i,4:6)=[1,0,0];
    end
end

%%% Y-coordinate demapping -----------------------------------------------
for i=1:K
    for k=1:8                %%% 再比较纵坐标
        dis(k)=temp(i,2)-y(k);
    end
    [di,num]=min(abs(dis));
    temp(i,2)=y(num);        %%% 纵坐标解调出来,并保存到原来矩阵中
   
    
    if y(num)==x(1)
        t_out(i,1:3)=[0,0,0];   %%% 纵坐标决定6个比特中的前三位
    end
    
    if y(num)==y(2)
        t_out(i,1:3)=[0,0,1];
    end
    
    if y(num)==y(3)
        t_out(i,1:3)=[0,1,1];
    end
    
    if y(num)==y(4)
        t_out(i,1:3)=[0,1,0];
    end
    
    if y(num)==y(5)
        t_out(i,1:3)=[1,1,0];
    end
    
    if y(num)==y(6)
        t_out(i,1:3)=[1,1,1];
    end
    
    if y(num)==y(7)
        t_out(i,1:3)=[1,0,1];
    end
    
    if y(num)==y(8)
        t_out(i,1:3)=[1,0,0];
    end
end

for i=1:K
    for m=1:6
        out(6*(i-1)+m)=t_out(i,m);     %%% P/S transform, the out is a serial binary sequence
    end
end

⌨️ 快捷键说明

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