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

📄 mmodmapper.m

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 M
字号:
function [output] = mModMapper(input,mode,res,boosting)
% Modulation Mapping of IEEE 802.16-2004 (WiMAX) 
%
%     output = mModMapper(input, mode <,res>,boosting)
%
% input : binary input vector or matrix (logical)
%         Matrices are processed column by column, one vector per column.
% output: complex output vector or matrix (double)
% mode  : number of coded bits per complex symbol   
%         1 = BPSK
%         2 = QPSK
%         4 = 16QAM
%         6 = 64QAM
% res   : output resolution in bits (8..32, optional)
%         If res is not specified the average power of the output is 1.
%         If res is specified the average output power is 
%         42 / 49 * (2^(res-1)-1)^2 - 9dB. Hence, the maximum magnitude
%        (64QAM, +9dB boosting) does not exceed the bit resolution.
%         In this case, the output can be rounded to obtain the integer
%         numbers in the required resolution.
% boosting :  boosting level of data subchannels
%             0:0dB
%             1:6dB
%             2:-6dB
%             3:9dB
%             4:3dB
%             5:-3dB
%             6:-9dB
%             7:-12dB
%         
% Matlab 7 Release 14 SP2

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Property of Freescale
%  Freescale Confidential Proprietary
%  Freescale Copyright (C) 2005 All rights reserved
%  ----------------------------------------------------------------------------
%  $RCSfile: mModMapper.m.rca $
%  $Revision: 1.7 $
%  $Date: Mon Oct 23 15:27:19 2006 $
%  Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[m,n]=size(input);

%if input is a row vector then make a column vector
if m==1
  input=input';
end  
[InputLen,blocks]=size(input);

%check input size and format
if ndims(input)>2
    error('Error: Input must be a vector or 2-dim matrix.');
end
if ~isreal(input)
    error('Error: Input vector must be real.');
end
if mod(InputLen,mode)
    error('Error: Block length must be a multiple of the mode.');
end

%check 'res' parameter
if exist('res','var')
    %normalize 
    factor = (2^(res-1)-1)*sqrt(42)/7;
    factor = factor * (10^(-9/20)); %9dB attenuation
else
    factor=1;
end

%map the bits according to the scheme
switch mode
    case 1
        output = 1-input.*2;
    case 2
        temp   = reshape(1-input.*2,2,InputLen*blocks/2)'/sqrt(2);
        output = reshape(temp(:,1) + i*temp(:,2),InputLen/2,blocks);
    case 4
        map=[ 1+i; 1+3i; 1-i; 1-3i;  3+i; 3+3i; 3-i; 3-3i; ...
             -1+i;-1+3i;-1-i;-1-3i; -3+i;-3+3i;-3-i;-3-3i]/sqrt(10);
        temp = [8 4 2 1]*reshape(input,4,InputLen*blocks/4);
        output = map(temp+1);
    case 6
        map=[ 3+3i; 3+i; 3+5i; 3+7i; 3-3i; 3-i; 3-5i; 3-7i; ...
              1+3i; 1+i; 1+5i; 1+7i; 1-3i; 1-i; 1-5i; 1-7i; ...
              5+3i; 5+i; 5+5i; 5+7i; 5-3i; 5-i; 5-5i; 5-7i; ...
              7+3i; 7+i; 7+5i; 7+7i; 7-3i; 7-i; 7-5i; 7-7i; ...
             -3+3i;-3+i;-3+5i;-3+7i;-3-3i;-3-i;-3-5i;-3-7i; ...
             -1+3i;-1+i;-1+5i;-1+7i;-1-3i;-1-i;-1-5i;-1-7i; ...
             -5+3i;-5+i;-5+5i;-5+7i;-5-3i;-5-i;-5-5i;-5-7i; ...
             -7+3i;-7+i;-7+5i;-7+7i;-7-3i;-7-i;-7-5i;-7-7i]/sqrt(42);
        temp = [32 16 8 4 2 1]*reshape(input,6,InputLen*blocks/6);
        output = map(temp+1);
    otherwise
        error('Error: Modulation mode %d not supported.',mode);
end

%here the output is normalized to an average power of 1.

switch boosting
    case 0  %0dB
    case 1  %6dB
        factor=factor*10^(6/20);
    case 2  %-6db
        factor=factor*10^(-6/20);
    case 3  %9dB
        factor=factor*10^(9/20);
    case 4  % 3dB
        factor=factor*10^(3/20);
    case 5  % -3dB
        factor=factor*10^(-3/20);
    case 6  %-9dB
        factor=factor*10^(-9/20);
    case 7  %-12dB
        factor=factor*10^(-12/20);
    otherwise
        error('Error: boosting mode %d not supported.',boosting);
end

%scale output according to the 'res' parameter and reshape to input format
output = reshape(output*factor,InputLen/mode,blocks);

%if input is a row vector make output also a row vector
if m==1
  output=output.';
end

⌨️ 快捷键说明

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