?? deqam8.m
字號:
%該程序用來完成對輸入信號進行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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -