%% Scramble Codeword Using PDSCH PRBS
% Scramble the contents of a codeword using the PDSCH scrambling sequence.
% Create cell-wide configuration structure for reference channel R.0, get PDSCH indices, and a create codeword.

enb = lteRMCDL('R.0');
pdsch = enb.PDSCH;
[~,pdschInfo] = ltePDSCHIndices(enb,pdsch,pdsch.PRBSet);
codedTrBlkSize = pdschInfo.G;
cw = randi([0 1],codedTrBlkSize,1);

%
% Generate PDSCH scrambling sequence, and scramble the codeword using the PDSCH scrambling sequence.

RNTI = 11;
ncw = 0;
pdschPrbsSeq = ltePDSCHPRBS(enb,RNTI,ncw,length(cw));
scrambled = xor(pdschPrbsSeq, cw);

% Copyright 2012 The MathWorks, Inc.