%% Check Data Block for CRC Error
% Check the effect of CRC decoding with and without a mask.
% Define a mask corresponding to the radio network temporary identifier (RNTI) equal to 12. Append RNTI-masked CRC parity bits to an all-ones matrix of one data block.

rnti = 12;
blkCrc = nrCRCEncode(ones(100,1),'24C',rnti);

% When you perform CRC decoding without a mask, err1 is equal to the RNTI because the CRC was masked during coding. The logical difference between the original CRC and the recalculated CRC is the CRC mask.

[blk,err1] = nrCRCDecode(blkCrc,'24C');
err1

% When you perform CRC decoding using the RNTI value as a mask, err is equal to 0.

[blk,err2] = nrCRCDecode(blkCrc,'24C',err1);
err2

% Copyright 2019 The MathWorks, Inc.