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

📄 deqam16.m

📁 OFDm模型里面的调制和解调相关源程序代码
💻 M
字号:
function [llr]=deqam16(x,h,SNR)
%本程序是计算经过16QAM调制信号的对数释然比信息,为软维特比译码提供信息源
%这里是根据输入信息点在坐标中的位置情况来判断对应二进制信息为的似然比的大小
%这里应该是对应四位二进制比特的释然比
%根据二进制对应比特数位置,分别求离输入信息点最近的0和1对应星座的似然比即位该比特的似然比
%具体理论公式见第一阶段文档附件中的均衡和解调方案
%输入参数:x:  经过16QAM调制的信号,长度为L
%          h:  信号经过的信号估计序列
%          SNR:经过的高斯信道的信噪比
%输出参数:llr:信号对应二进制序列的对数释然比信息
%                    8    7  |   3    4
%                    6    5  |   1    2
%             ---------------        
%                   14    13 |   9    10
%                   16    15 |   11   12
%
%王东洋
%2005-10-19
%星座图表
constel_diagram=[sqrt(2)/2+j*sqrt(2)/2, 1.5*sqrt(2)+j*sqrt(2)/2, sqrt(2)/2+j*1.5*sqrt(2), 1.5*sqrt(2)+j*1.5*sqrt(2),...%第一象限
                -sqrt(2)/2+j*sqrt(2)/2,-1.5*sqrt(2)+j*sqrt(2)/2,-sqrt(2)/2+j*1.5*sqrt(2),-1.5*sqrt(2)+j*1.5*sqrt(2),...%第二象限
                 sqrt(2)/2-j*sqrt(2)/2, 1.5*sqrt(2)-j*sqrt(2)/2, sqrt(2)/2-j*1.5*sqrt(2), 1.5*sqrt(2)-j*1.5*sqrt(2),...%第四象限
                -sqrt(2)/2-j*sqrt(2)/2,-1.5*sqrt(2)-j*sqrt(2)/2,-sqrt(2)/2-j*1.5*sqrt(2),-1.5*sqrt(2)-j*1.5*sqrt(2)]/sqrt(5);%第三象限
%SNR为信道信噪比,信号功率为1,转化为线性值
SNR_linr=10^(SNR/10);
%得到信道估计值的平方
h_square=abs(h).^2;
%len为输入信号的长度
len=length(x);
%存储似然比信息
llr=zeros(1,4*len);
%计算信号到各个星座点的映射距离
temp=[abs(x-constel_diagram(1)),abs(x-constel_diagram(2)),abs(x-constel_diagram(3)),abs(x-constel_diagram(4)),abs(x-constel_diagram(5)),abs(x-constel_diagram(6)),...
    abs(x-constel_diagram(7)),abs(x-constel_diagram(8)),abs(x-constel_diagram(9)),abs(x-constel_diagram(10)),abs(x-constel_diagram(11)),abs(x-constel_diagram(12)),...
    abs(x-constel_diagram(13)),abs(x-constel_diagram(14)),abs(x-constel_diagram(15)),abs(x-constel_diagram(16))].^2;
%下面是计算各个信息比特的似然比信息llr
for m=1:len
    temp2=temp(m:len:16*len);
    [y,z]=sort(temp2);
    
    switch z(1)
        case 1
        llr(4*(m-1)+1)=h_square(m)*(temp2(5)-temp2(1));
        llr(4*(m-1)+2)=h_square(m)*(temp2(9)-temp2(1));
        llr(4*(m-1)+3)=h_square(m)*(temp2(2)-temp2(1));
        llr(4*(m-1)+4)=h_square(m)*(temp2(3)-temp2(1));
        case 2
         llr(4*(m-1)+1)=h_square(m)*(temp2(5)-temp2(2));
         llr(4*(m-1)+2)=h_square(m)*(temp2(10)-temp2(2));
         llr(4*(m-1)+3)=h_square(m)*(temp2(2)-temp2(1));
         llr(4*(m-1)+4)=h_square(m)*(temp2(4)-temp2(2));
        case 3
         llr(4*(m-1)+1)=h_square(m)*(temp2(7)-temp2(3));
         llr(4*(m-1)+2)=h_square(m)*(temp2(9)-temp2(3));
         llr(4*(m-1)+3)=h_square(m)*(temp2(4)-temp2(3));
         llr(4*(m-1)+4)=h_square(m)*(temp2(3)-temp2(1));
        case 4
         llr(4*(m-1)+1)=h_square(m)*(temp2(7)-temp2(4));
         llr(4*(m-1)+2)=h_square(m)*(temp2(10)-temp2(4));
         llr(4*(m-1)+3)=h_square(m)*(temp2(4)-temp2(3));
         llr(4*(m-1)+4)=h_square(m)*(temp2(4)-temp2(2));
        case 5
         llr(4*(m-1)+1)=h_square(m)*(temp2(5)-temp2(1));
         llr(4*(m-1)+2)=h_square(m)*(temp2(13)-temp2(5));
         llr(4*(m-1)+3)=h_square(m)*(temp2(6)-temp2(5));
         llr(4*(m-1)+4)=h_square(m)*(temp2(7)-temp2(5));
        case 6
         llr(4*(m-1)+1)=h_square(m)*(temp2(6)-temp2(1));
         llr(4*(m-1)+2)=h_square(m)*(temp2(14)-temp2(6));
         llr(4*(m-1)+3)=h_square(m)*(temp2(6)-temp2(5));
         llr(4*(m-1)+4)=h_square(m)*(temp2(8)-temp2(6));
        case 7
         llr(4*(m-1)+1)=h_square(m)*(temp2(7)-temp2(3));
         llr(4*(m-1)+2)=h_square(m)*(temp2(13)-temp2(7));
         llr(4*(m-1)+3)=h_square(m)*(temp2(8)-temp2(7));
         llr(4*(m-1)+4)=h_square(m)*(temp2(7)-temp2(5));
        case 8
         llr(4*(m-1)+1)=h_square(m)*(temp2(8)-temp2(3));
         llr(4*(m-1)+2)=h_square(m)*(temp2(14)-temp2(6));
         llr(4*(m-1)+3)=h_square(m)*(temp2(8)-temp2(7));
         llr(4*(m-1)+4)=h_square(m)*(temp2(8)-temp2(6));
        case 9
         llr(4*(m-1)+1)=h_square(m)*(temp2(13)-temp2(9));
         llr(4*(m-1)+2)=h_square(m)*(temp2(9)-temp2(1));
         llr(4*(m-1)+3)=h_square(m)*(temp2(10)-temp2(9));
         llr(4*(m-1)+4)=h_square(m)*(temp2(11)-temp2(9));
        case 10
         llr(4*(m-1)+1)=h_square(m)*(temp2(13)-temp2(10));
         llr(4*(m-1)+2)=h_square(m)*(temp2(10)-temp2(2));
         llr(4*(m-1)+3)=h_square(m)*(temp2(10)-temp2(9));
         llr(4*(m-1)+4)=h_square(m)*(temp2(12)-temp2(10));
        case 11
         llr(4*(m-1)+1)=h_square(m)*(temp2(15)-temp2(11));
         llr(4*(m-1)+2)=h_square(m)*(temp2(11)-temp2(1));
         llr(4*(m-1)+3)=h_square(m)*(temp2(12)-temp2(11));
         llr(4*(m-1)+4)=h_square(m)*(temp2(11)-temp2(9));
        case 12
         llr(4*(m-1)+1)=h_square(m)*(temp2(15)-temp2(12));
         llr(4*(m-1)+2)=h_square(m)*(temp2(12)-temp2(2));
         llr(4*(m-1)+3)=h_square(m)*(temp2(12)-temp2(11));
         llr(4*(m-1)+4)=h_square(m)*(temp2(12)-temp2(10));
        case 13
         llr(4*(m-1)+1)=h_square(m)*(temp2(13)-temp2(9));
         llr(4*(m-1)+2)=h_square(m)*(temp2(13)-temp2(5));
         llr(4*(m-1)+3)=h_square(m)*(temp2(14)-temp2(13));
         llr(4*(m-1)+4)=h_square(m)*(temp2(15)-temp2(13));
        case 14
         llr(4*(m-1)+1)=h_square(m)*(temp2(14)-temp2(9));
         llr(4*(m-1)+2)=h_square(m)*(temp2(14)-temp2(6));
         llr(4*(m-1)+3)=h_square(m)*(temp2(14)-temp2(13));
         llr(4*(m-1)+4)=h_square(m)*(temp2(16)-temp2(14));
        case 15
         llr(4*(m-1)+1)=h_square(m)*(temp2(15)-temp2(11));
         llr(4*(m-1)+2)=h_square(m)*(temp2(15)-temp2(5));
         llr(4*(m-1)+3)=h_square(m)*(temp2(16)-temp2(15));
         llr(4*(m-1)+4)=h_square(m)*(temp2(15)-temp2(13));
       otherwise 
         llr(4*(m-1)+1)=h_square(m)*(temp2(16)-temp2(11));
         llr(4*(m-1)+2)=h_square(m)*(temp2(16)-temp2(6));
         llr(4*(m-1)+3)=h_square(m)*(temp2(16)-temp2(15));
         llr(4*(m-1)+4)=h_square(m)*(temp2(16)-temp2(14));
     end
 end
 llr=llr/SNR_linr;
 

⌨️ 快捷键说明

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