%% Get DCI Message Structure and Bits
% Extract and decode the PDCCH symbols from the control region of a subframe grid created by the DL waveform generator, lteRMCDLTool. Use the blind search function, ltePDCCHSearch, to search the common and UE-specific spaces by demasking all PDCCH candidates with the configured RNTI.
% Use a waveform generator to create a full subframe grid containing a reference PDSCH and associated DCI in UE-specific search space. Extract and decode all the PDCCH multiplex (control region) bits.

rmc = lteRMCDL('R.0');
[~,txGrid] = lteRMCDLTool(rmc,[1;0;0;1]);

pdcchSymbols = txGrid(ltePDCCHIndices(rmc));
rxPdcchBits = ltePDCCHDecode(rmc,pdcchSymbols);

%
% Configure the UE-specific parameters that affect the DCI message lengths to match those of the reference UE.

ueConfig.RNTI = rmc.PDSCH.RNTI;
ueConfig.EnableCarrierIndication = 'Off';
ueConfig.EnableSRSRequest = 'Off';
ueConfig.EnableMultipleCSIRequest = 'Off';
ueConfig.NTxAnts = 1;

%
% Use PDCCH blind search to find the DCI that schedules the PDSCH. Extract and display first DCI message structure from the search list. Compare the format of the DCI message returned in the previous step with the format used by the waveform generator.

[rxDCI,rxDCIBits] = ltePDCCHSearch(rmc,ueConfig,rxPdcchBits);

decDCI = rxDCI{1}
decDCIFormat = decDCI.DCIFormat
txDCIFormat = rmc.PDSCH.DCIFormat

% Copyright 2012 The MathWorks, Inc.