gusucode.com > wlan工具箱matlab源码程序 > wlan/wlanexamples/helperSubcarrierIndices.m

    function [dataIdx,pilotIdx] = helperSubcarrierIndices(cfg,fieldType)
% helperSubcarrierIndices Return the subcarrier indices within the FFT size
%
%   [DATAIDX,PILOTIDX] = helperSubcarrierIndices(CFGFORMAT,FIELDTYPE)
%   returns the data and pilot indices within the FFT size for the
%   specified format configuration object, CFGFORMAT, and specified
%   FIELDTYPE.
%
%   DATAIDX is a column vector containing the indices of data subcarriers.
%
%   PILOTIDX is a column vector containing the indices of pilot
%   subcarriers.
%
%   CFGFORMAT is the format configuration object of type <a href="matlab:help('wlanVHTConfig')">wlanVHTConfig</a>, 
%   <a href="matlab:help('wlanHTConfig')">wlanHTConfig</a>, or <a href="matlab:help('wlanNonHTConfig')">wlanNonHTConfig</a>, which specifies the parameters for
%   the VHT, HT-Mixed, and Non-HT formats, respectively.
%
%   FIELDTYPE is a string specifying the format of the field and must be
%   one of 'Legacy','HT' or 'VHT'.
%
%   [DATAIDX,PILOTIDX] = helperSubcarrierIndices(CHANBW,FIELDTYPE) returns
%   indices for the specified channel bandwidth. CHANBW must be one of
%   'CBW5', 'CBW10', 'CBW20', 'CBW40', 'CBW80' or 'CBW160'.
%
%   Example: Return indices for a VHT format configuration. 
%
%   cfgVHT = wlanVHTConfig;
%   [dataIdx,pilotIdx] = helperSubcarrierIndices(cfgVHT,'VHT')

% Copyright 2015 The MathWorks, Inc.

%#codegen

if ischar(cfg)
    coder.internal.errorIf( ~any(strcmp(cfg, {'CBW5', 'CBW10', ...
            'CBW20', 'CBW40', 'CBW80', 'CBW160'})), ...
        'wlan:helperSubcarrierIndices:InvalidChBandwidth');

    chanBW = cfg; 
else    
    validateattributes(cfg,{'wlanVHTConfig','wlanHTConfig','wlanNonHTConfig'}, ...
        {'scalar'},mfilename,'format configuration object');

    coder.internal.errorIf(isa(cfg,'wlanNonHTConfig') && ...
        ~strcmp(cfg.Modulation,'OFDM'), ...
            'wlan:helperSubcarrierIndices:InvalidNonHTModulation')

    chanBW = cfg.ChannelBandwidth;
end
fieldType = validatestring(fieldType,{'Legacy','HT','VHT'},mfilename,'Field type');
ofdmInfo = wlan.internal.wlanGetOFDMConfig(chanBW,'Long',fieldType);
dataIdx = ofdmInfo.DataIndices;
pilotIdx = ofdmInfo.PilotIndices;
end