?? sq4qam_gray_map.m
字號:
function out=sq4QAM_Gray_map(input)
%%%--------example---------------------
%%% input=[0 0 0 1 1 1 1 0]
%%% out=[1+j
%%% -1+j
%%% -1-j
%%% 1-j]
%%%將輸入的信息比特流映射為方形4QAM星座點;輸出為并行復數序列,為表示星座點的復數
%%%輸入序列長度應為2的倍數;每2個比特映射為一個星座點
%%% 'input' is the inputed source bit sequence
%%% 'output' is the mapped constellations, and is still a serial sequence
K=length(input)/2; %%% The number of symbols
d=1/sqrt(2); %%% The minimum distance between constellations is 2*d
x=[d,-d]; %%% coordinate matrix
y=[d,-d];
for i=1:K %%%將input變成K×2的矩陣,便于映射處理,每一行對應一個星座點
for k=1:2
temp(i,k)=input(2*(i-1)+k);
end
end
%%% mapping --------------------------------
%%% Y-coordinate ---------------------------%%% 2個比特中的前一位決定縱坐標,后一位決定橫坐標
for i=1:K
if temp(i,1)==0
max(i,2)=y(1);
else max(i,2)=y(2);
end
end
%%% X-coordinate --------------------------
for i=1:K
if temp(i,2)==0
max(i,1)=x(1);
else max(i,1)=x(2);
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; %%% parrallel complex constellations sequence
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -