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

📄 sq16qam_gray_demap.m

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

%%%----example--------------------------
%%% input=[1+3j
%%%        -1+j
%%%        1-3j]
%%% out=[0 0 0 1 0 1 1 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(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
    temp(i,:)=[real(input(i)),imag(input(i))]; %%% 复数矩阵变成实数矩阵,便于处理
end


%%% 解调采用比较横纵坐标,找最接近的横纵坐标的方法,相当于量化的思想
%%% X-coordinate demapping -----------------------------------------------
for i=1:K
    for k=1:4                %%% 先比较横坐标
        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,3:4)=[0,0];   %%% 横坐标决定4个比特中的后两位
    end
    if x(num)==x(2)
        t_out(i,3:4)=[0,1];
    end
    if x(num)==x(3)
        t_out(i,3:4)=[1,1];
    end
    if x(num)==x(4)
        t_out(i,3:4)=[1,0];
    end
end

%%% Y-coordinate demapping -----------------------------------------------
for i=1:K
    for k=1:4                %%% 先比较纵坐标
        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:2)=[0,0];   %%% 纵坐标决定4个比特中的前两位
    end
    if y(num)==y(2)
        t_out(i,1:2)=[0,1];
    end
    if y(num)==y(3)
        t_out(i,1:2)=[1,1];
    end
    if y(num)==y(4)
        t_out(i,1:2)=[1,0];
    end
end

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

clear K d x y temp t_out

   















⌨️ 快捷键说明

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