modulation.m
来自「B3g_phase2_C语言_Matlab程序及说明」· M 代码 · 共 40 行
M
40 行
function [Symbols] = Modulation(TxBits, ModScheme)
% This function Gray encodes binary bits into QPSK symbols onto antenna.
%
% function [Symbols] = Modulation(TxBits, ModScheme)
%
% Input:
% TxBits -- Transmit bits
% ModScheme -- Modulation type
% Output:
% Symbols -- Modulated symbols
% Note:
% Unit energy symbol constellation
% See also:
% None
% Description:
% Author(s): Wang Dongming, SEU, NCRL
j=sqrt(-1);
% Gray coded 16-QAM mapping vector
MapMatrix16QAM = [-1-j -1-3*j -1+j -1+3*j -3-j -3-3*j -3+j -3+3*j 1-j 1-3*j 1+j 1+3*j 3-j 3-3*j 3+j 3+3*j];
MapMatrix16QAM = MapMatrix16QAM/sqrt(10);
% Binary to Decimal order vector
vecOrder = (2.^(ModScheme-1:-1:0)).';
switch ModScheme
case 1
Symbols = TxBits*2 - 1;
case 2
Symbols = ((TxBits(:,1:2:end)*2 - 1) + j*(TxBits(:,2:2:end)*2 - 1))/sqrt(2);
case 4
matTxBits = vec2mat(TxBits,ModScheme);
vecTxBits = matTxBits * vecOrder + 1;
Symbols = MapMatrix16QAM(vecTxBits);
otherwise
disp('Modulation options out of range');
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?