?? sq16qam_gray_map.m
字號:
function out=sq16QAM_Gray_map(input)
%%%--------example---------------------
%%% input=[0 0 0 1 0 1 1 1 1 0 0 1]
%%% out=[1+3j
%%% -1+j
%%% 1-3j]
%%%將輸入的信息比特流映射為方形16QAM星座點(diǎn);輸出為并行復(fù)數(shù)序列,為表示星座點(diǎn)的復(fù)數(shù)
%%%輸入序列長度應(yīng)為4的倍數(shù);每4個(gè)比特映射為一個(gè)星座點(diǎn)
%%% 'input' is the inputed source bit sequence
%%% 'output' is the mapped constellations, and is still a serial sequence
K=length(input)/4; %%% The number of symbols
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 %%%將input變成K×4的矩陣,便于映射處理,每一行對應(yīng)一個(gè)星座點(diǎn)
for k=1:4
temp(i,k)=input(4*(i-1)+k);
end
end
%%% mapping --------------------------------
%%% Y-coordinate ---------------------------%%% 4個(gè)比特中的前兩位決定縱坐標(biāo),后兩位決定橫坐標(biāo)
for i=1:K
if [temp(i,1),temp(i,2)]==[0,0]
max(i,2)=y(1);
end
if [temp(i,1),temp(i,2)]==[0,1]
max(i,2)=y(2);
end
if [temp(i,1),temp(i,2)]==[1,1]
max(i,2)=y(3);
end
if [temp(i,1),temp(i,2)]==[1,0]
max(i,2)=y(4);
end
end
%%% X-coordinate --------------------------
for i=1:K
if [temp(i,3),temp(i,4)]==[0,0]
max(i,1)=x(1);
end
if [temp(i,3),temp(i,4)]==[0,1]
max(i,1)=x(2);
end
if [temp(i,3),temp(i,4)]==[1,1]
max(i,1)=x(3);
end
if [temp(i,3),temp(i,4)]==[1,0]
max(i,1)=x(4);
end
end
clear i;
clear k;
clear temp;
%%% j=sqrt(-1); %%%% if you have use j as a variable,then you must have to define j as a complex
%%%% if you want to use it as a complex sign
for i=1:K
p_out(i,:)=max(i,1)+max(i,2)*j; %%% generate complex constellations,and serial sequence
end
clear max;
out=p_out; %%% parallel complex constellations sequence
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -