deqam8.m

来自「OFDm模型里面的调制和解调相关源程序代码」· M 代码 · 共 82 行

M
82
字号
%该程序用来完成对输入信号进行4QAM解调,属于《链路级仿真软件设计》程序二的4QAM解调模块
%
%编程日期:2006-3-7
function [llr]=deqam8(x,h,SNR_db)
%[llr]=deqam8(x)
%x是复向量,其中向量元素表示输入到解调器中的信号
%h为信道估值向量,是复向量,其中向量元素表示对应采样时刻的信道状态。
%SNR_db为信道噪比。
%llr为x通过解调器后的输出信号,是实向量,表示经过相关解调后的数据“似然比“信息。
%SNR_db为信道信噪比,信号功率为1,噪声功率为n_power
%                             |   
%                             4
%                       3     |    2
%             ----7--------1---        
%                       8     |    5   
%                             6 
%                             |   
%
%星座图表
constel_diagram=[1,sqrt(2)/2+sqrt(2)/2*j,-sqrt(2)/2+sqrt(2)/2*j,j,sqrt(2)/2-sqrt(2)/2*j,-j,-1,-sqrt(2)/2-sqrt(2)/2*j];%[1 2 4 3 7 8 6 5]
%SNR为信道信噪比,信号功率为1,转化为线性值
SNR_linr=10^(SNR_db/10);
%得到信道估计值的平方
h_square=abs(h).^2;
%噪声方差
%len为输入信号的长度
len=length(x);
%存储似然比信息
llr=zeros(1,3*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))].^2;
%下面是计算各个信息比特的似然比信息llr
for m=1:len
    temp2=temp(m:len:8*len);
    [y,z]=sort(temp2);
    
    switch z(1)
        case 1
        llr(3*(m-1)+1)=h_square(m)*(temp2(5)-temp2(1));
        llr(3*(m-1)+2)=h_square(m)*(temp2(3)-temp2(1));
        llr(3*(m-1)+3)=h_square(m)*(temp2(2)-temp2(1));
        %llr(3*(m-1))=h_square(m)*(temp2(3)-temp2(1));
        case 2
         llr(3*(m-1)+1)=h_square(m)*(temp2(6)-temp2(2));
         llr(3*(m-1)+2)=h_square(m)*(temp2(4)-temp2(2));
         llr(3*(m-1)+3)=h_square(m)*(temp2(2)-temp2(1));
         %llr(3*(m-1)+4)=h_square(m)*(temp2(4)-temp2(2));
        case 3
         llr(3*(m-1)+1)=h_square(m)*(temp2(7)-temp2(3));
         llr(3*(m-1)+2)=h_square(m)*(temp2(3)-temp2(1));
         llr(3*(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(3*(m-1)+1)=h_square(m)*(temp2(8)-temp2(4));
         llr(3*(m-1)+2)=h_square(m)*(temp2(4)-temp2(2));
         llr(3*(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(3*(m-1)+1)=h_square(m)*(temp2(5)-temp2(1));
         llr(3*(m-1)+2)=h_square(m)*(temp2(7)-temp2(5));
         llr(3*(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(3*(m-1)+1)=h_square(m)*(temp2(6)-temp2(2));
         llr(3*(m-1)+2)=h_square(m)*(temp2(8)-temp2(6));
         llr(3*(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(3*(m-1)+1)=h_square(m)*(temp2(7)-temp2(3));
         llr(3*(m-1)+2)=h_square(m)*(temp2(7)-temp2(5));
         llr(3*(m-1)+3)=h_square(m)*(temp2(8)-temp2(7));
         %llr(4*(m-1)+4)=h_square(m)*(temp2(7)-temp2(5));
        otherwise
         llr(3*(m-1)+1)=h_square(m)*(temp2(8)-temp2(4));
         llr(3*(m-1)+2)=h_square(m)*(temp2(8)-temp2(6));
         llr(3*(m-1)+3)=h_square(m)*(temp2(8)-temp2(7));
         %llr(4*(m-1)+4)=h_square(m)*(temp2(8)-temp2(6));
     end
 end
 llr=llr/SNR_linr;
 

⌨️ 快捷键说明

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