main content

5g nr downlink csi reporting -凯发k8网页登录

this example shows how to compute downlink channel state information (csi) parameters such as the channel quality indicator (cqi), precoding matrix indicator (pmi), and rank indicator (ri), for multiple input multiple output (mimo) scenarios, as defined in ts 38.214 section 5.2.2, over a tapped delay line (tdl) channel. the example supports csi parameter computation for the type i single-panel, type i multi-panel, type ii codebooks, and enhanced type ii codebooks.

introduction

csi parameters are the quantities related to the state of a channel. the user equipment (ue) reports csi parameters to the access network node (gnb) as feedback. the csi feedback includes several parameters, such as the cqi, the pmi, and the ri. the ue uses the channel state information reference signal (csi-rs) to measure the csi feedback. upon receiving the csi parameters, the gnb schedules downlink data transmissions (such as modulation scheme, code rate, number of transmission layers, and mimo precoding) accordingly. this figure shows an overview of csi-rs transmission, csi computation and feedback, and the transmission of downlink data that is scheduled based on the csi parameters.

ri selection

the ri defines the number of possible layers for the downlink transmission under specific channel conditions. the ri also corresponds to the maximum number of uncorrelated paths that the downlink transmission can use. other csi parameters like the pmi and cqi are computed based on the rank provided by the ri. for given channel conditions, the hriselect function computes the cqi values for all valid values of number of transmission layers. the function returns the number of transmission layers that have maximum modulation and coding efficiency.

pmi selection

the pmi consists of a set of indices corresponding to the precoding matrix. the gnb can apply this precoding matrix for the downlink data transmission. the hdlpmiselect function reports a precoding matrix by considering a codebook from these supported codebooks:

  • type i single-panel codebooks, as defined in ts 38.214 tables 5.2.2.2.1-1 to 5.2.2.2.1-12

  • type i multi-panel codebooks, as defined in ts 38.214 tables 5.2.2.2.2-1 to 5.2.2.2.2-6

  • type ii codebooks, as defined in ts 38.214 tables 5.2.2.2.2-1 to 5.2.2.2.3-5

  • enhanced type ii codebooks, as defined in ts 38.214 tables 5.2.2.2.5-1 to 5.2.2.2.5-6

the pmi selection is based on the codebook type, the number of transmission layers, and other csi reporting configuration parameters such as antenna panel dimensions. each codebook consists of a set of precoding matrices. nr considers a dual-stage precoding matrix based on the codebooks design from ts 38.214 sections 5.2.2.2.1 to 5.2.2.2.3 and section 5.2.2.2.5.

w=w1w2

where,

w1 is a matrix representing a discrete fourier transform (dft) beam or beam group for both polarizations based on the codebook type

w2 can be any of the following based on the codebook type:

  • beam selection from w1

  • weighting coefficients for the beams in w1

  • cophasing values between two polarizations

for type i single-panel and multi-panel codebooks, the function computes signal to interference plus noise ratio (sinr) at the receiver side for all precoding matrices from the selected codebook and for the given channel conditions. the function reports the pmi as the set of indices i1, i2, as defined in ts 38.214 section 5.2.2.2.1 for type i single-panel codebooks and ts 38.214 section 5.2.2.2.2 for type i multi-panel codebooks. these indices correspond to a precoding matrix w, which gives the maximum sinr. type i single and multi-panel codebooks are useful for single-user mimo scenarios. this figure shows the procedure for pmi selection from type i single-panel and multi-panel codebooks.

type ii codebooks consider a set of orthogonal dft beams to form the precoding matrix. as mentioned above, the w1 matrix contains the information related to the dft beams. for the given channel conditions and the number of dft beams, the function computes the beam amplitude scaling and cophasing values (w2) for all the dft beams in each orthogonal beam group so that the linear combination of orthogonal beams approximates the eigenvector of the channel. the function reports the indices i1and i2, as defined in ts 38.214 section 5.2.2.2.3. these indices correspond to the precoding matrix w, which gives the maximum sinr. type ii codebook based pmi is more accurate than type i codebook based pmi, as multiple beams are considered in type ii codebooks for the approximation of channel eigenvector. because type ii codebooks consider multiple beams, multi-user mimo scenarios use type ii codebooks instead of type i codebooks. these figures show the pmi selection procedure from type ii codebooks.

this figure shows the quantization process in space domain (i.e., few beams in the approximation of channel eigenvector) in type ii codebooks to form w2 matrix for each layer.

because type ii codebooks support only up to rank 2, the standard introduces enhanced type ii codebooks. the pmi computation that is based on enhanced type ii codebooks extends type ii codebooks by supporting up to rank 4 with one overhead reduction technique. the beam amplitude scaling and cophasing values (also called beam combining coefficients) for all the beams are computed similar to type ii codebooks approach. with the rank extension, the feedback overhead increases linearly and with the number of subbands. for this amount of feedback, the uplink resources may not be sufficient. by taking the advantage of the frequency-domain correlation of beam combining coefficients, a process called dft or frequency-domain compression is employed for enhanced type ii codebooks to reduce the feedback overhead.

the figure shows the frequency-domain compression process.

along with frequency-domain compression, enhanced type ii codebooks limit the number of nonzero coefficients in the feedback by ignoring the weaker beam combining coefficients.

cqi selection

the cqi is an indicator of channel quality. the cqi value is a scalar in the range [0, 15]. the cqi value provides information about the highest modulation scheme and the code rate (mcs) suitable for the downlink transmission to achieve the required block error rate (bler) for given channel conditions.

the csi reference resource is a group of downlink frequency-domain and time-domain resources that are configured as defined in ts 38.214 section 5.2.2.5. the gnb transmits a single physical downlink shared channel (pdsch) transport block occupying the resource blocks called the csi reference resource, with a combination of modulation scheme and target code rate that correspond to each cqi index. the ue selects the highest possible cqi, when the pdsch transport block can be received with a transport block error probability not exceeding:

  • 0.1 when 'cqi-table' is 'table1' or 'table2'

  • 0.00001 when 'cqi-table' is 'table3'

the 'cqi-table' is a higher layer parameter that corresponds to the cqi versus mcs table, and the sinr lookup table is computed for this table. this example uses 'cqi-table' as 'table1' (ts 38.214 table 5.2.2.1-2). the relationship between the cqi indices, the modulation scheme, and the code rate (from which the transport block size is derived) is described in ts 38.214 tables 5.2.2.1-2 to 5.2.2.1-4.

the hcqiselect function computes the cqi value by considering the sinr values that correspond to the reported pmi. this function uses the precalculated lookup table of the cqi index versus sinri, as a reference, if you provide it.

cqi selection using sinr lookup table

the function maps the sinr values across all layers (corresponding to the reported pmi) to each codeword. for each codeword, the function compares the respective sinr with the sinri values from the table and then selects the cqi value against the maximum sinr, which is less than the codeword sinr. the function sets the cqi value so that the bler is less than or equal to 0.1 when operated at sinri. if a cqi index of 1 does not satisfy the bler condition, then the function sets the cqi index to 0. this figure shows the procedure for cqi selection.

cqi selection without sinr lookup table

the function computes the cqi values by using the sinr values across all layers corresponding to the reported pmi. based on the number of codewords, the function forms the combinations of cqi values and reports the one which satisfies the bler condition.

cqi versus sinr table

to create the lookup tables, update the nr pdsch throughput example by configuring the csi reference resource, as defined in ts 38.214 section 5.2.2.5. perform simulations for pdsch throughput by specifying the modulation scheme and code rate corresponding to each cqi, the channel conditions, and a finite range of sinr values with zero interference. map the sinr value observed at the receiver against each cqi index when the target bler is achieved. this figure shows the procedure for cqi versus sinr table creation.

outline of example

this example shows how to compute the cqi and pmi indices for a 4-by-4 mimo scenario over a tdl channel with the tdl-c delay profile, a delay spread of 300 nanoseconds, and a maximum doppler shift of 50 hz. it compares the time-domain and frequency-domain variations of cqi values against the time-domain and frequency-domain variations of sinr values for practical and perfect channel estimation scenarios. the example also highlights the time-domain and frequency-domain variations of the pmi values corresponding to the reported rank for practical and perfect channel estimation scenarios.

simulation length and snr point

set the length of the simulation in terms of the number of 10 ms frames. the snr (sinr with zero interference) is defined per resource element (re) and applies to each receive antenna. for an explanation of the snr definition that this example uses, see .

nframes = 5; % number of 10 ms frames
snrdb = 10;  % snr in db

carrier, bandwidth part, and csi-rs configuration

create a carrier configuration object representing a 10 mhz carrier with a subcarrier spacing of 15 khz.

carrier = nrcarrierconfig;
carrier.subcarrierspacing = 15;
carrier.nsizegrid = 52;

configure the size of the bandwidth part (bwp) and the start of the bwp relative to common resource block 0 (crb 0).

nstartbwp = 0;
nsizebwp = 52;

create a csi-rs configuration object representing a non-zero-power csi-rs (nzp-csi-rs) resource set with a set of nzp-csi-rs resources. make sure that the nzp-csi-rs resources have the same code division multiplexing (cdm) types and the same number of csi-rs ports, as defined in ts 38.214 section 5.2.2.3.1.

csirs = nrcsirsconfig;
csirs.csirstype = {'nzp','nzp','nzp'};
csirs.rownumber = [4 4 4];
csirs.numrb = 52;
csirs.rboffset = 0;
csirs.csirsperiod = [4 0];
csirs.symbollocations = {0, 0, 0};
csirs.subcarrierlocations = {0, 4, 8};
csirs.density = {'one','one','one'};

configure the number of transmit and receive antennas. the number of transmit antennas must be equal to the number of csi-rs ports because this example does not consider the mapping of antenna ports to physical antennas.

ntxants = csirs.numcsirsports(1);
nrxants = 4;

validate the csi-rs configuration object.

validatecsirsconfig(carrier,csirs,ntxants);

csi reporting configuration

specify the parameters for the cqi, pmi, and ri computation as a structure with these fields:

  • nsizebwp — size of the bwp in terms of the number of physical resource blocks (prbs)

  • nstartbwp — starting prb index of the bwp relative to crb 0

  • cqitable — channel quality indicator table ('table1', 'table2', 'table3'), as defined in ts 38.214 tables 5.2.2.1-2 to 5.2.2.1-4

  • codebooktype — codebook type for csi parameter computation ('type1singlepanel', 'type1multipanel', 'type2', 'etype2')

  • paneldimensions — antenna panel dimensions corresponding to the codebooktype field

if codebooktype is set to any one of ('type1singlepanel', 'type2', 'etype2'), the panel dimensions are in the form of [n1 n2] according to ts 38.214 table 5.2.2.2.1-2. this figure shows the supported panel dimensions.

if codebooktype is set to 'type1multipanel', the panel dimensions are in the form of [ng n1 n2] according to ts 38.214 table 5.2.2.2.2-1. this figure shows the supported type i multi-panel dimensions.

  • cqimode — mode of cqi reporting ('subband', 'wideband')

  • pmimode — mode of pmi reporting ('subband', 'wideband')

  • subbandsize — size of the subband, as defined in ts 38.214 table 5.2.1.4-2 (required only when cqimode or pmimode is 'subband')

  • prgsize — precoding resource block group (prg) size for the cqi calculation (required only when the reporting must be done for the report quantity 'cri-ri-i1-cqi' and codebooktype is configured as 'type1singlepanel', as defined in ts 38.214 section 5.2.1.4.2)

  • codebookmode — codebook mode according to which the codebooks are derived. the value must be 1 or 2. this field is applicable only when the codebooktype is specified as 'type1singlepanel' or 'type1multiplepanel'. when the codebooktype is specified as 'type1singlepanel', this field is required only when the number of transmission layers is 1 or 2 and the number of csi-rs ports is greater than 2. when the codebooktype is specified as 'type1multiplepanel', this field is required for all the number of transmission layers, but the codebookmode value 2 is applicable only for the panel configurations with ng value 2.

  • codebooksubsetrestriction — for type i single-panel and multi-panel codebooks, it is a restriction parameter pertaining to the codebook index set i1, that is, vlm or v~lm restriction parameter, as defined in ts 38.214 section 5.2.2.2.1. this field denotes the set of i1 indices ([i11, i12]) that are restricted from the consideration for the pmi computation. for type ii codebooks, this field restricts the maximum amplitudes that are allowed for four vector groups indicated by r1(k),r2(k) for k=0,1,2,3, as defined in ts 38.214 section 5.2.2.2.3. for enhanced type ii codebooks, this field restricts the maximum average amplitude coefficients that are allowed for four vector groups indicated by r1(k),r2(k) for k=0,1,2,3, as defined in ts 38.214 section 5.2.2.2.5. in any of the codebook types, this field is specified as a bitmap.

  • i2restriction — restriction parameter pertaining to the codebook index i2. this field denotes the set of i2 indices that are restricted from the consideration for the pmi computation. this field is applicable only when codebooktype is 'type1singlepanel'.

  • rirestriction — restriction parameter pertaining to the rank indicator, which implies the set of ranks that are restricted from usage for the ri computation.

  • numberofbeams — number of beams in the beam group per polarization. this field is applicable only when the codebooktype is specified as 'type2'. the value must be one of {2, 3, 4}.

  • phasealphabetsize — represents the range of the phases that are considered for the computation of i2 indices. this field is applicable only when the codebooktype is specified as 'type2'. the value must be one of {4, 8}. the value 4 represents the phases corresponding to qpsk and the value 8 represents the phases corresponding to 8-psk.

  • subbandamplitude — logical scalar that enables the reporting of differential amplitudes per subband when set to true and disables differential subband amplitude in pmi reporting when set to false. the value must be one of {true, false}. this field is applicable when codebooktype is specified as 'type2' and pmimode is 'subband'.

  • parametercombination — it is a positive scalar integer in the range 1...8. this is applicable when codebooktype is specified as 'etype2'. this parameter defines the number of beams and two other parameters as defined in ts 38.214 table 5.2.2.2.5-1.

  • numberofpmisubbandspercqisubband — represents the number of pmi subbands within one cqi subband, as defined in ts 38.214 section 5.2.2.2.5. it is a positive scalar integer, and it must be either 1 or 2.

configure csi reporting configuration parameters.

reportconfig.nstartbwp = nstartbwp;
reportconfig.nsizebwp = nsizebwp;
reportconfig.cqitable = 'table1';
reportconfig.codebooktype = 'type1singlepanel';
reportconfig.paneldimensions = [2 1];
reportconfig.cqimode = 'subband';
reportconfig.pmimode = 'subband';
reportconfig.subbandsize = 4;
reportconfig.prgsize = [];
reportconfig.codebookmode = 1;
reportconfig.codebooksubsetrestriction = [];
reportconfig.i2restriction = [];
reportconfig.rirestriction = [];
reportconfig.numberofbeams = 2;                    % applicable only when codebooktype is 'type2'
reportconfig.subbandamplitude = false;             % applicable only when codebooktype is 'type2'
reportconfig.phasealphabetsize = 4;                % applicable only when codebooktype is 'type2'
reportconfig.parametercombination = 2;             % applicable only when codebooktype is 'etype2'
reportconfig.numberofpmisubbandspercqisubband = 2; % applicable only when codebooktype is 'etype2'

propagation channel model configuration

create a tdl channel with the tdl-c delay profile, a delay spread of 300 nanoseconds, and a maximum doppler shift of 50 hz.

channel = nrtdlchannel;
channel.numtransmitantennas = ntxants;
channel.numreceiveantennas = nrxants;
channel.delayprofile = 'tdl-c';
channel.maximumdopplershift = 50;
channel.delayspread = 300e-9;

set the sampling rate for the channel model by using the value that the nrofdminfo function returns.

waveforminfo = nrofdminfo(carrier);
channel.samplerate = waveforminfo.samplerate;

get the maximum number of delayed samples by a channel multipath component. the maximum number of delayed samples is calculated from the channel path with the largest delay and the implementation delay of the channel filter. the number of samples that correspond to the maximum channel delay is required later to flush the channel filter to obtain the received signal.

chinfo = info(channel);
maxchdelay = ceil(max(chinfo.pathdelays*channel.samplerate))   chinfo.channelfilterdelay;

processing loop

for each slot, generate the csi-rs, transmit it through the channel, and then process at the receiver side to compute the cqi, pmi, and ri values. follow the steps for the transmit-to-receive processing for each slot.

  1. generate the resource grid — generate the slot grid that contains the csi-rs and map the slot grid from csi-rs ports to transmit antennas.

  2. generate the waveform — perform orthogonal frequency division multiplexing (ofdm) modulation on the generated grid by using the nrofdmmodulate function.

  3. model and apply a noisy channel — pass the waveform through a tdl-c fading channel, and then add the additive white gaussian noise (awgn). the snr is defined per re and applies to each receive antenna.

  4. perform timing synchronization and ofdm demodulation — for practical synchronization, correlate the received waveform with the csi-rs. for perfect synchronization, use the path gains and path filters of the channel. perform ofdm demodulation on the synchronized signal using the nrofdmdemodulate function.

  5. perform channel estimation — for practical channel estimation, use the csi-rs. for perfect channel estimation, use the path gains, the path filters, and the sample times of channel snapshots.

  6. compute cqi, pmi, and ri values — compute cqi, pmi, and ri values using practical and perfect channel estimations.

calculate total number of slots.

totslots = nframes*carrier.slotsperframe;

initialize variables to store cqi, pmi, ri, and subband sinr values for practical and perfect channel estimation scenarios.

after the completion of processing loop:

  • the variables cqipracticalperslot, cqiperfectperslot, sinrpersubbandpercwpractical, and sinrpersubbandpercwprerfect are multidimensional arrays of size numsbs-by-2-by-totslots. the numsbs value is equal to the number of subbands plus 1, that is, the corresponding wideband value followed by subband values. the second dimension value denotes the maximum possible number of codewords.

  • the variables pmipracticalperslot and pmiperfectperslot are arrays of structures of size totslots. the structure represents the pmi values with fields i1 and i2.

  • the variables ripracticalperslot and riperfectperslot are arrays of size 1-by-totslots.

cqipracticalperslot = [];
subbandcqipractical = [];
pmipracticalperslot = struct('i1',[],'i2',[]);
sinrpersubbandpercwpractical = [];
cqiperfectperslot = [];
subbandcqiperfect = [];
pmiperfectperslot = struct('i1',[],'i2',[]);
sinrpersubbandpercwperfect = [];
ripracticalperslot = [];
riperfectperslot = [];
% get number of csi-rs ports
csirsports = csirs.numcsirsports(1);
% get cdm lengths corresponding to configured csi-rs resources
cdmlengths = getcdmlengths(csirs);
% initialize the practical timing offset as zero. it is updated in the
% slots when the correlation is strong for practical synchronization.
offsetpractical = 0;
% initialize a variable to store the information of the slots
% where nzp-csi-rs resources are present. it is of length totslots.
totslotsbinaryvec = zeros(1,totslots);
% set rng state for repeatability
rng('default');
% loop over all slots
for nslot = 0:totslots - 1
    % create carrier resource grid for one slot
    csirsslotgrid = nrresourcegrid(carrier,csirsports);
    % update slot number in carrier configuration object
    carrier.nslot = nslot;
    % generate csi-rs indices and symbols
    csirsind = nrcsirsindices(carrier,csirs);
    csirssym = nrcsirs(carrier,csirs);
    % map csi-rs to slot grid
    csirsslotgrid(csirsind) = csirssym;
    % map csi-rs ports to transmit antennas
    wtx = eye(csirsports,ntxants);
    txgrid = reshape(reshape(csirsslotgrid,[],csirsports)*wtx,size(csirsslotgrid,1),size(csirsslotgrid,2),ntxants);
    % perform ofdm modulation to generate time-domain waveform
    txwaveform = nrofdmmodulate(carrier,txgrid);
    % append zeros at the end of the transmitted waveform to flush channel
    % content. these zeros take into account any delay introduced in the
    % channel. the channel delay is a mix of multipath delay and
    % implementation delay. this value may change depending on the sampling
    % rate, delay profile, and delay spread.
    txwaveform = [txwaveform; zeros(maxchdelay,size(txwaveform,2))]; %#ok
    % transmit waveform through channel
    [rxwaveform,pathgains,sampletimes] = channel(txwaveform);
    % generate and add awgn to received waveform
    snr = 10^(snrdb/10);                                                % linear snr value
    sigma = 1/(sqrt(2.0*nrxants*double(waveforminfo.nfft)*snr));        % noise standard deviation
    noise = sigma*complex(randn(size(rxwaveform)),randn(size(rxwaveform)));
    rxwaveform = rxwaveform   noise;
    % perform practical timing estimation. correlate the received waveform
    % with the csi-rs to obtain the timing offset estimate and the
    % correlation magnitude. use the hskipweaktimingoffset function to
    % update the receiver timing offset. if the correlation peak is weak,
    % the current timing estimate is ignored and the previous offset is
    % used.
    [t,mag] = nrtimingestimate(carrier,rxwaveform,csirsind,csirssym);
    offsetpractical = hskipweaktimingoffset(offsetpractical,t,mag);
    % get path filters
    pathfilters = getpathfilters(channel);
    % perform perfect timing estimation
    offsetperfect = nrperfecttimingestimate(pathgains,pathfilters);
    % perform time-domain offset correction for practical and
    % perfect timing estimation scenarios
    rxwaveformpractical = rxwaveform(1 offsetpractical:end,:);
    rxwaveformperfect = rxwaveform(1 offsetperfect:end,:);
    % perform ofdm demodulation on previously synchronized waveforms
    rxgridpractical = nrofdmdemodulate(carrier,rxwaveformpractical);
    rxgridperfect = nrofdmdemodulate(carrier,rxwaveformperfect);
    % append zeros when the timing synchronization results in an incomplete
    % slot
    symbperslot = carrier.symbolsperslot;
    k = size(rxgridpractical,1);
    lpractical = size(rxgridpractical,2);
    lperfect = size(rxgridperfect,2);
    if lpractical < symbperslot
        rxgridpractical = cat(2,rxgridpractical,zeros(k,symbperslot-lpractical,nrxants));
    end
    if lperfect < symbperslot
        rxgridperfect = cat(2,rxgridperfect,zeros(k,symbperslot-lperfect,nrxants));
    end
    rxgridpractical = rxgridpractical(:,1:symbperslot,:);
    rxgridperfect = rxgridperfect(:,1:symbperslot,:);
    % consider only the nzp-csi-rs symbols and indices for channel estimation
    nzpcsirssym = csirssym(csirssym ~= 0);
    nzpcsirsind = csirsind(csirssym ~= 0);
    % calculate practical channel estimate. use a time-averaging window
    % that covers all the transmitted csi-rs symbols.
    [practicalhest,nvarpractical] = nrchannelestimate(carrier,rxgridpractical, ...
        nzpcsirsind,nzpcsirssym,'cdmlengths',cdmlengths,'averagingwindow',[0 5]);
    % perform perfect channel estimation
    perfecthest = nrperfectchannelestimate(carrier,pathgains,pathfilters,offsetperfect,sampletimes);
    % get perfect noise estimate value from noise realization
    noisegrid = nrofdmdemodulate(carrier,noise(1 offsetperfect:end,:));
    nvarperfect = var(noisegrid(:));
    if ~isempty(nzpcsirsind)
        % set the totslotsbinaryvec value corresponding to the slot
        % index where nzp-csi-rs is present to 1
        totslotsbinaryvec(nslot 1) = 1;
        % calculate the ri value using practical channel estimate
        numlayerspractical = hriselect(carrier,csirs,reportconfig,practicalhest,nvarpractical,'maxse');
        % calculate cqi and pmi values using practical channel estimate
        [cqipractical,pmipractical,cqiinfopractical,pmiinfopractical] = hcqiselect(carrier,csirs, ...
            reportconfig,numlayerspractical,practicalhest,nvarpractical);
        numcodewordspr = size(cqipractical,2);
        numsbs = size(cqipractical,1);
        % store cqi, pmi, ri, and subband sinr values of each slot for the
        % practical channel estimation scenario. because the number of
        % codewords can vary based on the rank, append nans to the
        % cqi-related variables to account for the second codeword
        % information in the slots where only one codeword is present.
        ripracticalperslot(1,nslot 1) = numlayerspractical; %#ok 
        cqipracticalperslot(:,:,nslot 1) = [cqipractical nan(numsbs,2-numcodewordspr)]; %#ok 
        pmipracticalperslot(nslot 1) = pmipractical;
        subbandcqipractical(:,:,nslot 1) = [cqiinfopractical.subbandcqi nan(numsbs,2-numcodewordspr)]; %#ok 
        sinrpersubbandpercwpractical(:,:,nslot 1) = [cqiinfopractical.sinrpersubbandpercw nan(numsbs,2-numcodewordspr)]; %#ok 
        % calculate the ri value using perfect channel estimate
        numlayersperfect = hriselect(carrier,csirs,reportconfig,perfecthest,nvarperfect,'maxse');
        % calculate cqi and pmi values using perfect channel estimate
        [cqiperfect,pmiperfect,cqiinfoperfect,pmiinfoperfect] = hcqiselect(carrier,csirs, ...
            reportconfig,numlayersperfect,perfecthest,nvarperfect);
        numcodewordspe = size(cqiperfect,2);
        % store cqi, pmi, ri, and subband sinr values of each slot for the
        % perfect channel estimation scenario. because the number of
        % codewords can vary based on the rank, append nans to the
        % cqi-related variables to account for the second codeword
        % information in the slots where only one codeword is present.
        riperfectperslot(1,nslot 1) = numlayersperfect; %#ok 
        cqiperfectperslot(:,:,nslot 1) = [cqiperfect nan(numsbs,2-numcodewordspe)]; %#ok 
        subbandcqiperfect(:,:,nslot 1) = [cqiinfoperfect.subbandcqi nan(numsbs,2-numcodewordspe)]; %#ok 
        pmiperfectperslot(nslot 1) = pmiperfect;
        sinrpersubbandpercwperfect(:,:,nslot 1) = [cqiinfoperfect.sinrpersubbandpercw nan(numsbs,2-numcodewordspe)]; %#ok 
    end
end
% get the active slot numbers (1-based) in which nzp-csi-rs is present
activeslotnum = find(totslotsbinaryvec);
% fill the cqi, pmi and ri variables with nans in the slots where nzp-csi-rs is
% absent according to codebook type
[cqipracticalperslot,subbandcqipractical,pmipracticalperslot,sinrpersubbandpercwpractical, ...
    cqiperfectperslot,subbandcqiperfect,pmiperfectperslot,sinrpersubbandpercwperfect,ripracticalperslot, ...
    riperfectperslot] = fillinactiveslots(cqipracticalperslot,subbandcqipractical, ...
    pmipracticalperslot,sinrpersubbandpercwpractical,cqiperfectperslot,subbandcqiperfect,pmiperfectperslot, ...
    sinrpersubbandpercwperfect,ripracticalperslot,riperfectperslot,reportconfig,totslotsbinaryvec,activeslotnum);

compare cqi, pmi, and ri values reported in practical and perfect channel estimation scenarios

plot cqi indices

plot the wideband sinr values and wideband cqi values for each codeword for practical and perfect channel estimation scenarios. the plot shows only the slots in which the csi-rs is transmitted or in which the cqi is calculated. the figure shows how the sinr and the corresponding reported cqi vary across the slots due to channel fading.

plotwidebandcqiandsinr(cqipracticalperslot,cqiperfectperslot, ...
    sinrpersubbandpercwpractical,sinrpersubbandpercwperfect,activeslotnum);

figure contains 2 axes objects. axes object 1 with title wideband sinr values for codeword 1, xlabel slots, ylabel wideband sinr values in db contains 2 objects of type line. these objects represent codeword 1:perfect channel est., codeword 1:practical channel est.. axes object 2 with title wideband cqi values for codeword 1, xlabel slots, ylabel wideband cqi values contains 2 objects of type line. these objects represent codeword 1:perfect channel est., codeword 1:practical channel est..

plot the subband sinr values and subband cqi values for each codeword for practical and perfect channel estimation scenarios. the plot shows the variations of sinr and cqi values across the subbands for a specified slot number (0-based) if the cqi is reported in that slot. otherwise, plot is not generated because the cqi is not reported.

the plotsubbandcqiandsinr function plots the cqi values across all subbands only when cqimode is configured as 'subband'.

% provide slot number for which subband cqi values and pmi i2 indices must be plotted
slotnumforsbtype1 = 0; % consider slot number as 0 (0-based) here, because csi is
                       % reported in that slot for the configured csi-rs resource(s)
plotsubbandcqiandsinr(subbandcqipractical,subbandcqiperfect, ...
    sinrpersubbandpercwpractical,sinrpersubbandpercwperfect,activeslotnum,slotnumforsbtype1);

figure contains 2 axes objects. axes object 1 with title estimated subband sinr values for codeword 1 in slot 0, xlabel subbands, ylabel subband sinr values in db contains 2 objects of type line. these objects represent codeword 1:perfect channel est., codeword 1:practical channel est.. axes object 2 with title estimated subband cqi values for codeword 1 in slot 0, xlabel subbands, ylabel subband cqi values contains 2 objects of type line. these objects represent codeword 1:perfect channel est., codeword 1:practical channel est..

plot pmi and ri indices

first plot in this section shows the variations of ri indices due to channel fading conditions, for practical and perfect channel estimation scenarios. the plot shows only the slots in which the csi-rs is transmitted or in which ri is calculated.

codebook type 'type1singlepanel'

the below code shows the variations of pmi due to channel fading conditions, for practical and perfect channel estimation scenarios.

the pmi indices are i1:[i1,1,i1,2,i1,3] and i2, as defined in ts 38.214 section 5.2.2.2.1.

the first plot shows the rank and the corresponding pmi i1 indices variation across multiple slots.

the second plot shows the variation in i2 indices across the:

  • slots when the pmimode is specified as 'wideband'

  • subbands in the specified slot when the pmimode is specified as 'subband'

codebook type 'type1multipanel'

the below code shows the variations of pmi due to channel fading conditions, for practical and perfect channel estimation scenarios.

the pmi indices are i1:[i1,1,i1,2,i1,3,i1,4,1,i1,4,2,i1,4,3] and i2:[i2,0,i2,1,i2,2], as defined in ts 38.214 section 5.2.2.2.2.

in this case, the first two plots show the rank and the corresponding pmi i1 indices (i1,1 to i1,4,3) variation across the slots.

the third plot shows the variation in each of the i2 indices (i2,0 to i2,2) across the:

  • slots when the pmimode is specified as 'wideband'

  • subbands in the specified slot when the pmimode is specified as 'subband'

codebook type 'type2' or 'etype2'

the below code shows the grid of beams by highlighting the dft vectors or beams that are used to construct the precoding matrix, for practical and perfect channel estimation scenarios. the plot shows the type ii or enhanced type ii pmi related information for a specified slot number (0-based), if pmi is reported in that slot. otherwise, plot is not generated because the pmi is not reported.

for type ii codebooks, the pmi indices are defined in ts 38.214 section 5.2.2.2.3. these indices are:

  • i1:[i1,1,i1,2,i1,3,1,i1,4,1] and i2:[i2,1,1] for single layer and subbandamplitude as 'false'

  • i1:[i1,1,i1,2,i1,3,1,i1,4,1] and i2:[i2,1,1,i2,2,1] for single layer and subbandamplitude as 'true'

  • i1:[i1,1,i1,2,i1,3,1,i1,4,1,i1,3,2,i1,4,2] and i2:[i2,1,1,i2,1,2] for two layers and subbandamplitude as 'false'

  • i1:[i1,1,i1,2,i1,3,1,i1,4,1,i1,3,2,i1,4,2] and i2:[i2,1,1,i2,2,1,i2,1,2,i2,2,2] for two layers and subbandamplitude as 'true'

for enhanced type ii codebooks, the pmi indices are defined in ts 38.214 section 5.2.2.2.5. these indices are:

  • i1:[i1,1,i1,2,i1,5,i1,6,1,i1,7,1,i1,8,1] and i2:[i2,3,1,i2,4,1,i2,5,1] for single layer

  • i1:[i1,1,i1,2,i1,5,i1,6,1,i1,7,1,i1,8,1,i1,6,2,i1,7,2,i1,8,2] and i2:[i2,3,1,i2,4,1,i2,5,1,i2,3,2,i2,4,2,i2,5,2] for two layers

  • i1:[i1,1,i1,2,i1,5,i1,6,1,i1,7,1,i1,8,1,i1,6,2,i1,7,2,i1,8,2,i1,6,3,i1,7,3,i1,8,3] and i2:[i2,3,1,i2,4,1,i2,5,1,i2,3,2,i2,4,2,i2,5,2,i2,3,3,i2,4,3,i2,5,3] for three layers

  • i1:[i1,1,i1,2,i1,5,i1,6,1,i1,7,1,i1,8,1,i1,6,2,i1,7,2,i1,8,2,i1,6,3,i1,7,3,i1,8,3,i1,6,4,i1,7,4,i1,8,4] and i2:[i2,3,1,i2,4,1,i2,5,1,i2,3,2,i2,4,2,i2,5,2,i2,3,3,i2,4,3,i2,5,3,i2,3,4,i2,4,4,i2,5,4] for four layers

the first plot shows the rank variations, and second plot shows the grid of beams for practical and perfect channel estimation scenarios.

% to see the pmi and ri plots for the type i single or multi-panel
% codebooks, set the showtype1pmiandriplots flag to true
showtype1pmiandriplots = true;
% to see the pmi and ri plots for the type ii codebooks, set the
% showtype2pmi flag to true
showtype2pmiri = true;
if (strcmpi(reportconfig.codebooktype,'type1singlepanel') || strcmpi(reportconfig.codebooktype,'type1multipanel')) && showtype1pmiandriplots
    plottype1pmiandri(pmipracticalperslot,pmiperfectperslot,ripracticalperslot, ...
        riperfectperslot,activeslotnum,slotnumforsbtype1);
elseif (strcmpi(reportconfig.codebooktype,'type2') || strcmpi(reportconfig.codebooktype,'etype2')) && showtype2pmiri
    slotnumfortype2pmi = 0; % 0-based
    plottype2pmiandri(pmipracticalperslot,pmiperfectperslot,ripracticalperslot, ...
        riperfectperslot,reportconfig.paneldimensions,reportconfig.numberofbeams,activeslotnum,slotnumfortype2pmi);
end

figure contains 4 axes objects. axes object 1 with title ri values, xlabel slots, ylabel ri values contains 2 objects of type line. these objects represent perfect channel est., practical channel est.. axes object 2 with title pmi: i11 indices, xlabel slots, ylabel i11 indices contains 2 objects of type line. these objects represent perfect channel est., practical channel est.. axes object 3 with title pmi: i12 indices, xlabel slots, ylabel i12 indices contains 2 objects of type line. these objects represent perfect channel est., practical channel est.. axes object 4 with title pmi: i13 indices, xlabel slots, ylabel i13 indices contains 2 objects of type line. these objects represent perfect channel est., practical channel est..

figure contains an axes object. the axes object with title pmi: i2 indices for all subbands in slot 0, xlabel subbands, ylabel i2 indices contains 2 objects of type line. these objects represent perfect channel est., practical channel est..

summary and further exploration

this example shows how to compute downlink csi parameters such as the cqi and pmi from type i single-panel codebooks and ri for a mimo scenario with a tdl channel. the example also supports the computation of csi parameters using type i multi-panel, type ii, and enhanced type ii codebooks.

you can modify carrier, channel, csi-rs resource configurations, and csi reporting configuration parameters (such as the codebook type, the mode of cqi and pmi reporting, and the subband size) and observe the variations in the computed cqi, pmi, and ri values across time (slots) and frequency (subbands).

references

[1] 3gpp ts 38.214. "nr; physical layer procedures for data." 3rd generation partnership project; technical specification group radio access network.

local functions

this example uses these local functions to validate the csi-rs configuration object and to plot the computed cqi, pmi, and ri values.

function validatecsirsconfig(carrier,csirs,ntxants)
%   validates the csi-rs configuration, given the carrier specific
%   configuration object, csi-rs configuration object, and the number of
%   transmit antennas.
    % validate the number of csi-rs ports
    if ~isscalar(unique(csirs.numcsirsports))
        error('nr5g:invalidcsirsports', ...
            'all the csi-rs resources must be configured to have the same number of csi-rs ports.');
    end
    % validate the cdm lengths
    if ~iscell(csirs.cdmtype)
        cdmtype = {csirs.cdmtype};
    else
        cdmtype = csirs.cdmtype;
    end
    if (~all(strcmpi(cdmtype,cdmtype{1})))
        error('nr5g:invalidcsirscdmtypes', ...
            'all the csi-rs resources must be configured to have the same cdm lengths.');
    end
    if ntxants ~= csirs.numcsirsports(1)
        error('nr5g:invalidnumtxants',['number of transmit antennas (' num2str(ntxants) ...
            ') must be equal to the number of csi-rs ports (' num2str(csirs.numcsirsports(1)) ').']);
    end
    % check for the overlap between the csi-rs indices
    csirsind = nrcsirsindices(carrier,csirs,"outputresourceformat",'cell');
    numres = numel(csirsind);
    csirsindall = cell(1,numres);
    ratioval = csirs.numcsirsports(1)/prod(getcdmlengths(csirs));
    for residx = 1:numres
        if ~isempty(csirsind{residx})
            grid = nrresourcegrid(carrier,csirs.numcsirsports(1));
            [~,tempind] = nrextractresources(csirsind{residx},grid);
            if numel(tempind)/numel(csirsind{residx}) ~= ratioval
                error('nr5g:overlappedcsirsressingleresource',['csi-rs indices of resource ' ...
                    num2str(residx) ' must be unique. try changing the symbol or subcarrier locations.']);
            end
            csirsindall{residx} = tempind(:);
            for idx = 1:residx-1
                overlappedind = ismember(csirsindall{idx},csirsindall{residx});
                if any(overlappedind)
                    error('nr5g:overlappedcsirsresmultipleresources',['the resource elements of the ' ...
                        'configured csi-rs resources must not overlap. try changing the symbol or ' ...
                        'subcarrier locations of csi-rs resource ' num2str(idx) ' and resource ' num2str(residx) '.']);
                end
            end
        end
    end
end
function cdmlengths = getcdmlengths(csirs)
%   returns the cdm lengths, given the csi-rs configuration object.
    cdmtype = csirs.cdmtype;
    if ~iscell(csirs.cdmtype)
        cdmtype = {csirs.cdmtype};
    end
    cdmtypeopts = {'nocdm','fd-cdm2','cdm4','cdm8'};
    cdmlengthopts = {[1 1],[2 1],[2 2],[2 4]};
    cdmlengths = cdmlengthopts{strcmpi(cdmtypeopts,cdmtype{1})};
end
function [cqipracticalperslot,subbandcqipractical,pmipracticalperslot,sinrpersubbandpercwpractical,cqiperfectperslot, ...
    subbandcqiperfect,pmiperfectperslot,sinrpersubbandpercwperfect,ripracticalperslot,riperfectperslot] = fillinactiveslots(cqipracticalperslot, ...
    subbandcqipractical,pmipracticalperslot,sinrpersubbandpercwpractical,cqiperfectperslot,subbandcqiperfect,pmiperfectperslot, ...
    sinrpersubbandpercwperfect,ripracticalperslot,riperfectperslot,reportconfig,totslotsbinaryvec,activeslots)
%   returns the cqi, pmi, and ri related variables filled with nans in the
%   slots where nzp-csi-rs is not present according to the codebook type from
%   the report configuration structure. note that the cqi, pmi, and ri
%   variables are returned as empty if there are no nzp-csi-rs resources,
%   that is, no active slots in the entire simulation duration.
    % compute the indices of the slots and the number of slots in which
    % nzp-csi-rs is not present
    inactiveslotidx = ~totslotsbinaryvec;
    numinactiveslots = nnz(inactiveslotidx);
    
    if ~isempty(activeslots)
        numcqisbs = size(cqipracticalperslot,1);
    
        % get the codebook type
        codebooktype = 'type1singlepanel';
        if isfield(reportconfig,'codebooktype')
            codebooktype = validatestring(reportconfig.codebooktype,{'type1singlepanel','type1multipanel','type2','etype2'},'fillinactiveslots','codebooktype field');
        end
    
        % fill the cqi, pmi, and ri variables with nans in the slots where nzp-csi-rs is
        % not present
        cqipracticalperslot(:,:,inactiveslotidx) = nan(numcqisbs,2,numinactiveslots);
        subbandcqipractical(:,:,inactiveslotidx) = nan(numcqisbs,2,numinactiveslots);
        sinrpersubbandpercwpractical(:,:,inactiveslotidx) = nan(numcqisbs,2,numinactiveslots);
        cqiperfectperslot(:,:,inactiveslotidx) = nan(numcqisbs,2,numinactiveslots);
        subbandcqiperfect(:,:,inactiveslotidx) = nan(numcqisbs,2,numinactiveslots);
        sinrpersubbandpercwperfect(:,:,inactiveslotidx) = nan(numcqisbs,2,numinactiveslots);
        ripracticalperslot(inactiveslotidx) = nan;
        riperfectperslot(inactiveslotidx) = nan;
    
        numi1indices = 3;
        numi2indices = 1;
        if strcmpi(codebooktype,'type1multipanel')
            numi1indices = 6;
            numi2indices = 3;
        end
        numpmisbs = size(pmiperfectperslot(activeslots(1)).i2,2);
        [pmiperfectperslot(inactiveslotidx),pmipracticalperslot(inactiveslotidx)] = deal(struct('i1',nan(1,numi1indices),'i2',nan(numi2indices,numpmisbs)));
    end
end
function plotwidebandcqiandsinr(cqipracticalperslot,cqiperfectperslot,sinrpersubbandpercwpractical,sinrpersubbandpercwperfect,activeslotnum)
%   plots the wideband sinr and wideband cqi values for each codeword
%   across all specified active slots (1-based) (in which the cqi is
%   reported as other than nan) for practical and perfect channel
%   estimation cases.
    % check if there are no slots in which nzp-csi-rs is present
    if isempty(activeslotnum)
        disp('no cqi data to plot, because there are no slots in which nzp-csi-rs is present.');
        return;
    end
    cqipracticalpercw = permute(cqipracticalperslot(1,:,:),[1 3 2]);
    cqiperfectpercw = permute(cqiperfectperslot(1,:,:),[1 3 2]);
    sinrpercwpractical = permute(sinrpersubbandpercwpractical(1,:,:),[1 3 2]);
    sinrpercwperfect = permute(sinrpersubbandpercwperfect(1,:,:),[1 3 2]);
    % extract wideband cqi indices for slots where nzp-csi-rs is present
    cqipracticalpercwactiveslots = cqipracticalpercw(1,activeslotnum,:);
    cqiperfectpercwactiveslots = cqiperfectpercw(1,activeslotnum,:);
    widebandsinrpractical = 10*log10(sinrpercwpractical(1,activeslotnum,:));
    widebandsinrperfect = 10*log10(sinrpercwperfect(1,activeslotnum,:));
    if isempty(reshape(cqipracticalpercwactiveslots(:,:,1),1,[]))
        disp('no cqi data to plot, because all cqi values are nans.');
        return;
    end
    figure();
    plotwbcqisinr(widebandsinrperfect,widebandsinrpractical,211,activeslotnum,'sinr');
    plotwbcqisinr(cqiperfectpercwactiveslots,cqipracticalpercwactiveslots,212,activeslotnum,'cqi');
end
function plotwbcqisinr(perfectvals,practicalvals,subplotidx,activeslotnum,inptext)
%   plots the wideband sinr and wideband cqi values for each codeword
%   across all specified active slots (1-based) (in which the cqi is
%   reported as other than nan) for practical and perfect channel
%   estimation cases.
    subplot(subplotidx)
    plot(perfectvals(:,:,1),'r-o');
    hold on;
    plot(practicalvals(:,:,1),'b-*');
    if ~all(isnan(perfectvals(:,:,2))) % two codewords
        hold on;
        plot(perfectvals(:,:,2),'r:s');
        hold on;
        plot(practicalvals(:,:,2),'b:d');
        title(['wideband ' inptext ' values for codeword 1&2']);
        legend({'codeword 1:perfect channel est.','codeword 1:practical channel est.','codeword 2:perfect channel est.','codeword 2:practical channel est.'});
    else
        title(['wideband ' inptext ' values for codeword 1']);
        legend({'codeword 1:perfect channel est.','codeword 1:practical channel est.'});
    end
    xlabel('slots');
    if strcmpi(inptext,'sinr')
        units = ' in db';
    else
        units = '';
    end
    ylabel(['wideband ' inptext ' values' units]);
    xticks(1:size(perfectvals,2));
    xticklables = num2cell(activeslotnum(:)-1);
    xticklabels(xticklables);
    [lowerbound,upperbound] = bounds([practicalvals(:);perfectvals(:)]);
    ylim([lowerbound-1 upperbound 3.5]);
end
function plotsubbandcqiandsinr(subbandcqipractical,subbandcqiperfect,sinrpercwpractical,sinrpercwperfect,activeslotnum,nslot)
%   plots the sinr and cqi values for each codeword across all the subbands
%   for practical and perfect channel estimation cases for the given slot
%   number (0-based) among all specified active slots (1-based). the
%   function does not plot the values if cqimode is 'wideband' or if the
%   cqi and sinr values are all nans in the given slot.
    % check if there are no slots in which nzp-csi-rs is present
    if isempty(activeslotnum)
        disp('no cqi data to plot, because there are no slots in which nzp-csi-rs is present.');
        return;
    end
    numsubbands = size(subbandcqipractical,1);
    if numsubbands > 1 && ~any(nslot 1 == activeslotnum) % check if the cqi values are reported in the specified slot
        disp(['for the specified slot (' num2str(nslot) '), cqi values are not reported. please choose another slot number.']);
        return;
    end
    % plot subband cqi values
    if numsubbands > 1 % subband mode
        subbandcqipercwpractical = subbandcqipractical(2:end,:,nslot 1);
        subbandcqipercwperfect = subbandcqiperfect(2:end,:,nslot 1);
        subbandsinrpercwpractical = 10*log10(sinrpercwpractical(2:end,:,nslot 1));
        subbandsinrpercwperfect = 10*log10(sinrpercwperfect(2:end,:,nslot 1));
        figure();
        plotsbcqisinr(subbandsinrpercwperfect,subbandsinrpercwpractical,numsubbands,211,nslot,'sinr')
        plotsbcqisinr(subbandcqipercwperfect,subbandcqipercwpractical,numsubbands,212,nslot,'cqi');
    end
end
function plotsbcqisinr(perfectvals,practicalvals,numsubbands,subplotidx,nslot,inptext)
%   plots the sinr and cqi values for each codeword across all the subbands
%   for practical and perfect channel estimation cases for the given slot
%   number (0-based). the function does not plot the values if cqimode is
%   'wideband' or if the cqi and sinr values are all nans in the given
%   slot.
    subplot(subplotidx)
    plot(perfectvals(:,1),'ro-');
    hold on;
    plot(practicalvals(:,1),'b*-');
    if ~all(isnan(perfectvals(:,2))) % two codewords
        hold on;
        plot(perfectvals(:,2),'rs:');
        hold on;
        plot(practicalvals(:,2),'bd:');
        legend({'codeword 1:perfect channel est.','codeword 1:practical channel est.','codeword 2:perfect channel est.','codeword 2:practical channel est.'});
        title(['estimated subband ' inptext ' values for codeword 1&2 in slot ' num2str(nslot)]);
    else % single codeword
        legend({'codeword 1:perfect channel est.','codeword 1:practical channel est.'});
        title(['estimated subband ' inptext ' values for codeword 1 in slot ' num2str(nslot)]);
    end
    if strcmpi(inptext,'sinr')
        units = ' in db';
    else
        units = '';
    end
    xlabel('subbands');
    ylabel(['subband ' inptext ' values' units]);
    xticks(1:numsubbands);
    xticklables = num2cell(1:numsubbands);
    xticklabels(xticklables);
    xlim([0 numsubbands 1]);
    [lowerbound,upperbound] = bounds([perfectvals(:);practicalvals(:)]);
    ylim([lowerbound-1 upperbound 3.5]);
end
function plottype1pmiandri(pmipracticalperslot,pmiperfectperslot,ripracticalperslot,riperfectperslot,activeslotnum,nslot)
%   plots the ri and pmi i1 indices across all specified active slots
%   (1-based), for practical and perfect channel estimation scenarios. the
%   function also plots the i2 indices of practical and perfect channel
%   estimation scenarios across all specified active slots when the pmi
%   mode is 'wideband' or plots i2 indices across all the subbands for the
%   specified slot number (0-based) when the pmi mode is 'subband'.
    % check if there are no slots in which nzp-csi-rs is present
    if isempty(activeslotnum)
        disp('no pmi and ri data to plot, because there are no slots in which nzp-csi-rs is present.');
        return;
    end
    
    numi1indices = numel(pmipracticalperslot(activeslotnum(1)).i1);
    if numi1indices == 6
        codebooktype = 'type1multipanel';
    else
        codebooktype = 'type1singlepanel';
    end
    
    % extract wideband pmi indices (i1 values) for slots where nzp-csi-rs
    % is present
    i1perfectvalsactiveslots = reshape([pmiperfectperslot(activeslotnum).i1],numi1indices,[])';
    i1practicalvalsactiveslots = reshape([pmipracticalperslot(activeslotnum).i1],numi1indices,[])';
    
    if isempty(i1perfectvalsactiveslots)
        disp('no pmi and ri data to plot, because all pmi and ri values are nans.');
        return;
    end
    
    figure;
    % plot ri
    plotri(ripracticalperslot,riperfectperslot,activeslotnum,411);
    
    % extract and plot i11 indices
    i11perfectvals = i1perfectvalsactiveslots(:,1);
    i11practicalvals = i1practicalvalsactiveslots(:,1);
    plotixxindices(i11perfectvals,i11practicalvals,activeslotnum,412,'i11');
    % extract and plot i12 indices
    i12perfectvals = i1perfectvalsactiveslots(:,2);
    i12practicalvals = i1practicalvalsactiveslots(:,2);
    plotixxindices(i12perfectvals,i12practicalvals,activeslotnum,413,'i12');
    % extract and plot i13 indices
    i13perfectvals = i1perfectvalsactiveslots(:,3);
    i13practicalvals = i1practicalvalsactiveslots(:,3);
    plotixxindices(i13perfectvals,i13practicalvals,activeslotnum,414,'i13');
    
    % plot the i141, i142 and i143 indices in type i multi-panel case
    if strcmpi(codebooktype,'type1multipanel')
        figure()
        % extract and plot i141 indices
        i141perfectvals = i1perfectvalsactiveslots(:,4);
        i141practicalvals = i1practicalvalsactiveslots(:,4);
        plotixxindices(i141perfectvals,i141practicalvals,activeslotnum,311,'i141');
        % extract and plot i142 indices
        i142perfectvals = i1perfectvalsactiveslots(:,5);
        i142practicalvals = i1practicalvalsactiveslots(:,5);
        plotixxindices(i142perfectvals,i142practicalvals,activeslotnum,312,'i142');
    
        % extract and plot i143 indices
        i143perfectvals = i1perfectvalsactiveslots(:,6);
        i143practicalvals = i1practicalvalsactiveslots(:,6);
        plotixxindices(i143perfectvals,i143practicalvals,activeslotnum,313,'i143');
    end
    % get the number of subbands
    numsubbands = size(pmipracticalperslot(activeslotnum(1)).i2,2);
    % get the number of i2 indices according to codebook type
    numi2indices = 1;
    if strcmpi(codebooktype,'type1multipanel')
        numi2indices = 3;
    end
    % get number of active slots
    numactiveslots = numel(activeslotnum);
    % extract i2 values
    i2perfectvals = reshape([pmiperfectperslot(activeslotnum).i2],[numsubbands,numi2indices,numactiveslots]);     % of size numactiveslots-by-numi2indices-numsubbands
    i2practicalvals = reshape([pmipracticalperslot(activeslotnum).i2],[numsubbands,numi2indices,numactiveslots]); % of size numactiveslots-by-numi2indices-numsubbands
    % plot i2 values
    if numsubbands == 1 % wideband mode
        figure;
        % in type i single-panel case, there is only one i2 index. the
        % first column of i2perfectvals and i2practicalvals corresponds to
        % i2 index. in type i multi-panel case, the i2 values are a set of
        % three indices i20, i21, and i22. each column of i2perfectvals and
        % i2practicalvals correspond to i20, i21, and i22 indices. extract
        % and plot the respective index values
        if strcmpi(codebooktype,'type1singlepanel')
            % extract and plot i2 values in each slot
            i2perfectvals = reshape(i2perfectvals(:,1,:),[],numactiveslots).';
            i2practicalvals = reshape(i2practicalvals(:,1,:),[],numactiveslots).';
            plotixxindices(i2perfectvals,i2practicalvals,activeslotnum,111,'i2');
        else
            % extract and plot i20 values in each slot
            i20perfectvals = reshape(i2perfectvals(:,1,:),[],numactiveslots).';
            i20practicalvals = reshape(i2practicalvals(:,1,:),[],numactiveslots).';
            plotixxindices(i20perfectvals,i20practicalvals,activeslotnum,311,'i20');
            % extract and plot i21 values in each slot
            i21perfectvals = reshape(i2perfectvals(:,2,:),[],numactiveslots).';
            i21practicalvals = reshape(i2practicalvals(:,2,:),[],numactiveslots).';
            plotixxindices(i21perfectvals,i21practicalvals,activeslotnum,312,'i21');
            % extract and plot i22 values in each slot
            i22perfectvals = reshape(i2perfectvals(:,3,:),[],numactiveslots).';
            i22practicalvals = reshape(i2practicalvals(:,3,:),[],numactiveslots).';
            plotixxindices(i22perfectvals,i22practicalvals,activeslotnum,313,'i22');
        end
    else % subband mode
        if any(nslot 1 == activeslotnum)
    
            % in subband mode, plot the pmi i2 indices corresponding to the
            % specified slot number
            figure;
            if strcmpi(codebooktype,'type1singlepanel')
                % extract and plot i2 values
                pmisbi2perfect = pmiperfectperslot(nslot 1).i2(1,:);
                pmisbi2practical = pmipracticalperslot(nslot 1).i2(1,:);
                ploti2xindices_sb(pmisbi2perfect,pmisbi2practical,numsubbands,nslot,111,'i2');
            else
                % extract and plot i20 values
                pmisbi20perfect = pmiperfectperslot(nslot 1).i2(1,:);
                pmisbi20practical = pmipracticalperslot(nslot 1).i2(1,:);
                ploti2xindices_sb(pmisbi20perfect,pmisbi20practical,numsubbands,nslot,311,'i20');
                
                % extract and plot i21 values
                pmisbi21perfect = pmiperfectperslot(nslot 1).i2(2,:);
                pmisbi21practical = pmipracticalperslot(nslot 1).i2(2,:);
                ploti2xindices_sb(pmisbi21perfect,pmisbi21practical,numsubbands,nslot,312,'i21');
    
                % extract and plot i22 values
                pmisbi22perfect = pmiperfectperslot(nslot 1).i2(3,:);
                pmisbi22practical = pmipracticalperslot(nslot 1).i2(3,:);
                ploti2xindices_sb(pmisbi22perfect,pmisbi22practical,numsubbands,nslot,313,'i22');
            end
        else
            disp(['for the specified slot (' num2str(nslot) '), pmi i2 indices are not reported. please choose another slot number.'])
        end
    end
end
function plottype2pmiandri(pmipracticalperslot,pmiperfectperslot,ripracticalperslot,riperfectperslot,paneldims,numbeams,activeslotnum,nslot)
%   plots the grid of beams by highlighting the beams that are used for the
%   precoding matrix generation for the specified slot number (0-based),
%   for practical and perfect channel estimation scenarios.
    % check if there are no slots in which nzp-csi-rs is present
    if isempty(activeslotnum)
        disp('no pmi and ri data to plot, because there are no slots in which nzp-csi-rs is present.');
        return;
    end
    plotri(ripracticalperslot,riperfectperslot,activeslotnum,111);
    if ~any(nslot 1 == activeslotnum)
        disp(['for the specified slot (' num2str(nslot) '), pmi values are not reported. please choose another slot number.']);
    else
        pmipractical = pmipracticalperslot(nslot 1);
        pmiperfect = pmiperfectperslot(nslot 1);
        figure();
        plottype2gridofbeams(pmipractical,paneldims,numbeams,'practical channel estimation scenario',1);
        hold on;
        plottype2gridofbeams(pmiperfect,paneldims,numbeams,'perfect channel estimation scenario',2);
    end
end
function plotri(ripracticalperslot,riperfectperslot,activeslotnum,subplotindex)
%   plots the ri values across all specified active slots (1-based), for
%   practical and perfect channel estimation scenarios.
    % get number of active slots
    numactiveslots = numel(activeslotnum);
    % extract ri values for slots where nzp-csi-rs is present
    riperfectvalsactiveslots = riperfectperslot(activeslotnum)';
    ripracticalvalsactiveslots = ripracticalperslot(activeslotnum)';
    
    if isempty(riperfectvalsactiveslots)
        disp('no ri data to plot, because all ri values are nans.');
        return;
    end
    
    figure;
    subplot(subplotindex);
    plot(riperfectvalsactiveslots,'r-o');
    hold on;
    plot(ripracticalvalsactiveslots,'b-*');
    xlabel('slots')
    ylabel('ri values');
    xticks(1:numactiveslots);
    xticklables = num2cell(activeslotnum(:)-1);
    xticklabels(xticklables);
    [~,upperbound] = bounds([riperfectvalsactiveslots; ripracticalvalsactiveslots]);
    xlim([0 numactiveslots 8]);
    ylim([0 upperbound 1]);
    yticks(0:upperbound 1);
    title('ri values')
    legend({'perfect channel est.','practical channel est.'});
end
function plottype2gridofbeams(pmiset,paneldims,numbeams,chesttype,subplotnum)
%   plots the grid of beams by highlighting the beams that are used for the
%   type ii codebook based precoding matrix generation.
    n1 = paneldims(1);
    n2 = paneldims(2);    
    % get the oversampling factors
    o1 = 4;
    o2 = 1   3*(n2 ~= 1);
    % extract q1, q2 values
    qset = pmiset.i1(1:2);
    q1 = qset(1)-1;
    q2 = qset(2)-1;
    % extract i12 value
    i12 = pmiset.i1(3);
    s = 0;
    % find the n1, n2 values for all the beams, as defined in ts 38.214
    % section 5.2.2.2.3
    n1_i12 = zeros(1,numbeams);
    n2_i12 = zeros(1,numbeams);
    for beamidxi = 0:numbeams-1
        i12minussval = i12 - s;
        xvalues = numbeams-1-beamidxi:n1*n2-1-beamidxi;
        cvalues = zeros(numel(xvalues),1);
        for xidx = 1:numel(xvalues)
            if xvalues(xidx) >= numbeams-beamidxi
                cvalues(xidx) = nchoosek(xvalues(xidx),numbeams-beamidxi);
            end
        end
        indices = i12minussval >= cvalues;
        maxidx = find(indices,1,'last');
        xvalue = xvalues(maxidx);
        ei = cvalues(maxidx);
        s = s ei;
        ni = n1*n2 - 1 - xvalue;
        n1_i12(beamidxi 1) = mod(ni,n1);
        n2_i12(beamidxi 1) = (ni-n1_i12(beamidxi 1))/n1;
    end
    m1 = o1*(0:n1-1)   q1;
    m2 = o2*(0:n2-1)   q2;
    % calculate the indices of orthogonal basis set which corresponds to
    % the reported i12 value
    m1_lbeams = o1*(n1_i12)   q1;
    m2_lbeams = o2*(n2_i12)   q2;
    orthogonalbeams = [repmat(m1,1,length(m2));reshape(repmat(m2,length(m1),1),1,[])]';
    % plot the grid of beams
    numcirlcesinrow = n1*o1;
    numcirlcesincol = n2*o2;
    subplot(2,1,subplotnum);
    circleradius = 1;
    for colidx = 0:numcirlcesincol-1
        for rowidx = 0:numcirlcesinrow-1
            p = nsidedpoly(1000, 'center', [2*rowidx 2*colidx], 'radius', circleradius);
            if any(prod(orthogonalbeams == [rowidx colidx],2))
                h2 = plot(p, 'facecolor', 'w','edgecolor','r','linewidth',2.5);
                hold on;
                if any(prod([m1_lbeams' m2_lbeams'] == [rowidx colidx],2))
                    h3 = plot(p, 'facecolor', 'g','linestyle','-.');                
                end
            else
                h1 = plot(p, 'facecolor', 'w');
            end
            hold on;
        end
    end
    rowlength = 2*circleradius*o1;
    collength = 2*circleradius*o2;
    for n2 = 0:n2-1
        for n1 = 0:n1-1
            x1 = -1*circleradius   rowlength*n1;
            x2 = x1   rowlength;
            y1 = -1*circleradius   collength*n2;
            y2 = y1   collength;
            x = [x1, x2, x2, x1, x1];
            y = [y1, y1, y2, y2, y1];
            plot(x, y, 'b-', 'linewidth', 2);
            hold on;
        end
    end
    
    xlabel('n1o1 beams');
    ylabel('n2o2 beams');
    axis equal;
    set(gca,'xtick',[],'ytick',[]);
    legend([h1 h2 h3],{'oversampled dft beams',['orthogonal basis set with [q1 q2] = [' num2str(q1) ' ' num2str(q2) ']'],'selected beam group'},'location','northeast');
    title(['grid of beams or dft vectors for ' chesttype]);
end
function plotixxindices(ixxperfectvals,ixxpracticalvals,activeslotnum,subplotinp,pmiidxtype)
%   plots i11, i12, i13 indices in case of type i single-panel codebooks
%   and plots i141, i142, and i143 in case of type i multi-panel codebooks.
    % plot ixx values
    subplot(subplotinp)
    plot(ixxperfectvals,'r-o');
    hold on;
    plot(ixxpracticalvals,'b-*');
    xlabel('slots')
    ylabel([pmiidxtype ' indices']);
    % get number of active slots
    numactiveslots = numel(activeslotnum);
    xticks(1:numactiveslots);
    xticklables = num2cell(activeslotnum(:)-1);
    xticklabels(xticklables);
    [lowerbound,upperbound] = bounds([ixxperfectvals; ixxpracticalvals]);
    xlim([0 numactiveslots 8]);
    ylim([lowerbound-2 upperbound 2]);
    title(['pmi: ' pmiidxtype ' indices']);
    legend({'perfect channel est.','practical channel est.'});
end
function ploti2xindices_sb(pmisbi2perfect,pmisbi2practical,numsubbands,nslot,subplotinp,pmiidxtype)
%   plots i2 indices in case of type i single-panel codebooks and plots
%   i20, i21, and i22 in case of type i multi-panel codebooks.
    subplot(subplotinp)
    plot(pmisbi2perfect,'r-o');
    hold on;
    plot(pmisbi2practical,'b-*');
    title(['pmi: ' pmiidxtype ' indices for all subbands in slot ' num2str(nslot)]);
    xlabel('subbands')
    ylabel([pmiidxtype ' indices']);
    xticks(1:numsubbands);
    xticklabels(num2cell(1:numsubbands));
    [lowerbound,upperbound] = bounds([pmisbi2perfect pmisbi2practical]);
    yticks(lowerbound:upperbound);
    yticklabels(num2cell(lowerbound:upperbound));
    xlim([0 numsubbands 1])
    ylim([lowerbound-1 upperbound 1]);
    legend({'perfect channel est.','practical channel est.'});
end

see also

functions

  • | | | | |

objects

  • | |

related topics

网站地图