%% Deprecode Symbols After SC-FDMA Demodulation
% Deprecode symbols after SC-FDMA demodulation and symbol extraction from the received resource grid.
% Create an UL RMC configuration structure, resource grid, and bit stream.

rmc = lteRMCUL('A3-2');
[puschInd, info] = ltePUSCHIndices(rmc,rmc.PUSCH);
ueDim = lteULResourceGridSize(rmc);
bits = randi([0,1],info.G,rmc.PUSCH.NLayers);

%
% Scramble bits, create modulated symbols, and perform UL precoding and resource mapping.

scrBits = lteULScramble(rmc,bits);
symbols = lteSymbolModulate(scrBits,rmc.PUSCH.Modulation);
precodedSymbols = lteULPrecode(symbols,rmc.NULRB);
grid = lteULResourceGrid(rmc);
grid(puschInd) = precodedSymbols;

%
% Perform SC-FDMA modulation and demodulation.

[timeDomainSig,infoScfdma] = lteSCFDMAModulate(rmc,grid);
rxGrid = lteSCFDMADemodulate(rmc,timeDomainSig);

%
% Extract PUSCH from grid and perform UL deprecoding.

rxPrecoded = rxGrid(puschInd);
dePrecodedSymbols = lteULDeprecode(rxPrecoded,rmc.NULRB);

% Copyright 2012 The MathWorks, Inc.