📄 modulate.m
字号:
function modsymbols=modulate(modutype,moduinput)
%function modulate and mapping
% moduletype:input
% 1:BPSK;
% 2:QPSK
% 3:16QAM
% 4:64QAM
% moduinput: input databits
inputbits=moduinput;
type=modutype;
full_len=length(inputbits);
switch type
case 1
% BPSK modulate
table=exp(j.*[0,-pi]); % 生成BPSK星座图
table=table([2,1]);
inmodu=inputbits;
modsymbols=table(inmodu+1); % 实现输入比特流的BPSK映射
case 2
% QPSK modulate
table=exp(j*[-3/4*pi 3/4*pi 1/4*pi -1/4*pi]); % 生成QPSK星座图
table=table([0 1 3 2]+1); % 转换成按照00,01,10,11排列的顺序
inmodu=reshape(inputbits,2,full_len/2); % 把输入序列分成两路
modsymbols=table([2 1]*inmodu+1); % 实现输入比特流的QPSK映射
case 3
% 16QAM modulate
m=1;
for k=-3:2:3
for l=-3:2:3
table(m)=(k+j*l)/sqrt(10); % ?是否是归一化,问题
m=m+1;
end
end
table=table([0 1 3 2 4 5 7 6 12 13 15 14 8 9 11 10]+1);
inmodu=reshape(inputbits,4,full_len/4); % 把输入序列分成四路
modsymbols=table([8 4 2 1]*inmodu+1); % 实现输入比特流的16QAM映射
case 4
m=1;
for k=-7:2:7
for l=-7:2:7
table(m)=(k+j*l)/sqrt(42);
m=m+1;
end
end
table=table([[0 1 3 2 7 6 4 5]...
8+[0 1 3 2 7 6 4 5]...
24+[0 1 3 2 7 6 4 5]...
16+[0 1 3 2 7 6 4 5]...
56+[0 1 3 2 7 6 4 5]...
48+[0 1 3 2 7 6 4 5]...
32+[0 1 3 2 7 6 4 5]...
40+[0 1 3 2 7 6 4 5]]+1);
inmodu=reshape(inputbits,6,full_len/6); % 把输入序列分成六路
modsymbols=table([32 16 8 4 2 1]*inmodu+1); % 实现输入比特流的64QAM映射
otherwise
fprintf('error');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -