⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapping.m

📁 国外大学的同志作出来的好程序
💻 M
字号:
function output=mapping(info, constell, priority_type);
%Mapping maps info into two dimensional constellations.
%priority_type sets the Most Signficant Bit.
%
if nargin<2 | nargin>3,
    disp('[Mapping]Number of inputs should be 2 or 3.');
    return;
end
if nargin==2 | (nargin==3 && isempty(priority_type)),
    priority_type='msb_first';
end

if size(constell,1)>1 & size(constell, 2)>1,
    disp('[Mapping]Error: Only two dimensional constellations are supported.');
    return;
end
constell_rate=log2(length(constell));
if strcmp(lower(priority_type), 'msb_first');
    mapping_radix=2.^[constell_rate-1:-1:0];
elseif strcmp(lower(priority_type), 'lsb_first');
    mapping_radix=2.^[0: constell_rate-1];
else
    disp('[Mapping]Error: Wrong priority type!');
    return;
end

%pad info with some zeros if needed.
tval=mod(size(info, 1), constell_rate);
if tval~=0,
    info=[info; zeros(constell_rate-tval, size(info, 2))];
end

%modulation
mapping_blknum=size(info, 1)/constell_rate;
output=zeros(mapping_blknum, size(info, 2));
for ic=1: mapping_blknum,
    currentInputVec=info((ic-1)*constell_rate+1: ic*constell_rate, :);
    currentInput=mapping_radix*currentInputVec;
    output(ic, :)=constell(currentInput+1);
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -