%% Rank Indication example
% This example shows how to populate an empty resource grid for RMC R.13 with cell-specific reference signal symbols. The signal is passed through a channel and OFDM demodulated. Estimates of the channel and noise power spectral density are used for RI and PMI calculation. A CodebookSubset bitmap of all ones means that no codebook subset restriction is applied, allowing any PMI/RI combination applicable for the configured transmission scheme to be selected during RI selection.
% Create empty resource grid and populate with cell specific reference symbols. Set enb.PDSCH.CodebookSubset to all ones so the PMI selection is unconstrained

enb = lteRMCDL('R.13');
enb.PDSCH.CodebookSubset = '1111111111111111';
reGrid = lteResourceGrid(enb);
reGrid(lteCellRSIndices(enb)) = lteCellRS(enb);
[txWaveform,txInfo] = lteOFDMModulate(enb,reGrid);

%
% Initialize the channel configuration structure (chcfg), filter the signal through a channel and demodulate the signal.

chcfg.DelayProfile = 'EPA';
chcfg.NRxAnts = 4;
chcfg.DopplerFreq = 5;
chcfg.MIMOCorrelation = 'Low';
chcfg.SamplingRate = txInfo.SamplingRate;
chcfg.Seed = 1;
chcfg.InitPhase = 'Random';
chcfg.ModelType = 'GMEDS';
chcfg.NTerms = 16;
chcfg.NormalizeTxAnts = 'On';
chcfg.NormalizePathGains = 'On';
chcfg.InitTime = 0;

rxWaveform = lteFadingChannel(chcfg,txWaveform);
rxSubframe = lteOFDMDemodulate(enb,rxWaveform);

%
% Estimate corresponding channel, including noise spectral density and reference signal subcarriers. Use lteRISelect to calculate RI & PMI

cec.FreqWindow = 1;
cec.TimeWindow = 15;
cec.InterpType = 'cubic';
cec.PilotAverage = 'UserDefined';
cec.InterpWinSize = 1;
cec.InterpWindow = 'Centered';
[hest,noiseEst] = lteDLChannelEstimate(enb,cec,rxSubframe);
[ri,pmi] = lteRISelect(enb,enb.PDSCH,hest,noiseEst)

% Copyright 2012 The MathWorks, Inc.