function [ output ] = modulation( input , modulation )
%星座映射
if ~isempty(findstr(modulation, 'BPSK'))
b_table=[-1 1];
out_bits=b_table(input+1);%-1表示0,1表示1
elseif ~isempty(findstr(modulation, 'QPSK'))
q_blocks = ceil(length(input)/2);
q_t = zeros(1,2*q_blocks-length(input));
q_input1 = [input q_t];
q_input2 = reshape(q_input1,2,q_blocks);
q_table=[-1-i -1+i 1-i 1+i];%-1-i表示00,-1+i表示01,1-i表示10,1+i表示11;
q_m=1;
for q_k = 1:q_blocks
out_qpsk(q_m) = q_table([2 1]*q_input2(:,q_k)+1);
q_m=q_m+1;
end
out_bits = out_qpsk;
elseif ~isempty(findstr(modulation, '16QAM'))
n = 1;
for k = -3:2:3
for q = -3:2:3
table(n) = k + q * i;%生成16个点
n = n+1;
end
end
table1 = reshape(table ,4 ,4);%将矩阵排成4行4列
inter = table1(4,:); table1(4,:) = table1(3,:); table1(3,:) = inter;%将矩阵的3,4行一换
inter1 = table1(:,4); table1(:,4) = table1(:,3); table1(:,3) = inter1;%将矩阵的3,4列一换
blocks = ceil(length(input)/4);
t = zeros(1,4*blocks-length(input));
input1 = [input t];
input2 = reshape(input1,4,blocks);
m=1;
for l = 1:blocks
out_qam16(m) = table1([8 4 2 1]*input2(:,l)+1);%将0 1序列与点值对应起来
m=m+1;
end
out_bits = out_qam16;
elseif ~isempty(findstr(modulation, '64QAM'))
n = 1;
for qam_k = -7:2:7
for qam_j = -7:2:7
qam_table(n) = qam_k + i*qam_j;%生成64个点
n = n+1;
end
end
qam_table1 = reshape(qam_table ,8 ,8);%将矩阵排成8行8列
int = qam_table1(4,:); qam_table1(4,:) = qam_table1(3,:); qam_table1(3,:) = int;%将矩阵的3,4行一换
int1 = qam_table1(6,:); qam_table1(6,:) = qam_table1(5,:); qam_table1(5,:) = int1;%将矩阵的5,6行一换
qam_table1(5:8,:) = flipud(qam_table1(5:8,:)); %矩阵的上半部分作上下翻转
int2 = qam_table1(:,4); qam_table1(:,4) = qam_table1(:,3); qam_table1(:,3) = int2;%将矩阵的3,4列一换
int3 = qam_table1(:,6); qam_table1(:,6) = qam_table1(:,5); qam_table1(:,5) = int3;%将矩阵的5,6列一换
qam_table1(:,5:8) = fliplr(qam_table1(:,5:8)); %矩阵的右半部分作左右翻转
qam_blocks = ceil(length(input)/6);
qam_t = zeros(1,6*qam_blocks-length(input));
qam_input1 = [input qam_t];
qam_input2 = reshape(qam_input1 , 6 , qam_blocks);
qam_m = 1;
for qam_l = 1:qam_blocks
out_qam64(qam_m) = qam_table1([32 16 8 4 2 1]*qam_input2(:,qam_l)+1);
qam_m = qam_m + 1;
end
out_bits = out_qam64;
else
error('undefined modulation');
end
l=length(out_bits);
c=ceil(l/52);
t=zeros(1,c*52-l);
t1=[out_bits t];
output(1,:)=t1;
ofdm.rar_ofdm
版权申诉
136 浏览量
2022-07-15
04:26:30
上传
评论
收藏 16KB RAR 举报
![avatar](https://profile-avatar.csdnimg.cn/fca2fc36c4174e7caf12f1c9ba2c9265_weixin_42657024.jpg!1)
邓凌佳
- 粉丝: 66
- 资源: 1万+
最新资源
- MyBatisCodeHelperPro 3.3.2-2322 2023.2-2024.1
- 基于Python的简单的学生成绩管理程序设计(课程设计)
- jdk-8u20-windows-x64安装版本-jdk-8u301-linux-x64解压版
- 植物大战僵尸杂交版 修改阳光和冷却
- html css js网页设计ntion-model-for-开发笔记
- 数据库课程设计-processing开发笔记
- matlab画图sic-开发demo
- 数据库原理课程设计-图书馆数据库管理系统
- IEC101Sim IEC870-5-101协议仿真主站、子站 (含源码 C++Builder)
- 2212503007陈熙炜跨境2202作业2.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)