📄 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 + -