%% Perform Turbo Rate Recovery
% Create a codeword from a transport block then rate recover the codeword back into a set of coded code blocks. The transport block is originally segmented into a single code block so the rateRecovered output variable is a cell array containing a single turbo coded code block.
% Define the transport block length prior to CRC and turbo coding, code word length, redundancy version, and CRC polynomial. Use these parameters to perform coding operations.

trBlkLen = 135; 
codewordLen = 450; 
rv = 0;
crcPoly = '24A';

%

trblockwithcrc = lteCRCEncode(zeros(trBlkLen,1),crcPoly);
codeblocks = lteCodeBlockSegment(trblockwithcrc);
turbocodedblocks = lteTurboEncode(codeblocks);
codeword = lteRateMatchTurbo(turbocodedblocks,codewordLen,rv);
rateRecovered = lteRateRecoverTurbo(codeword,trBlkLen,rv)

% rateRecovered is a cell array with a single coded code block of size indicated above.
% Further turbo decoding, desegmentation and CRC decoding of rateRecovered would result in a decoded transport block of length equal to the original transport block. Note that the trBlkLen parameter of the lteRateRecoverTurbo function is the transport block length before CRC and turbo coding, not the length after turbo coding or rate matching.
% Copyright 2012 The MathWorks, Inc.