%% Back-to-Back LDPC Code Block Segmentation and Desegmentation
% Perform code block segmentation of a random sequence of binary input data.

bgn = 1;
blklen = 10000;
cbs = nrCodeBlockSegmentLDPC(randi([0 1],blklen,1),bgn);

% When the base graph number is 1, segmentation occurs whenever the input length is greater than 8448. The input data of length 10000 is split into two code block segments of length 5280. The code block segments have filler bits and CRC attached.

size(cbs)

% Concatenate the code block segments.

[blk,err] = nrCodeBlockDesegmentLDPC(cbs,bgn,blklen);

% The concatenated result is of the same size as the original input with CRC and filler bits removed.

blkSize = size(blk)

% Verify if the CRC decoding was successful by checking the error vector.

err

% Copyright 2019 The MathWorks, Inc.