%% Perform Polar Rate Recovery
% Create a polar encoded random block of 512 bits and perform polar rate matching using nrRateMatchPolar. Perform polar rate recovery. Verify the results are identical to the original polar encoded input.
% Specify an information block of 56 bits and an output of 864 bits for rate matching.

N = 512;
K = 56;
E = 864;
in = randi([0 1],N,1);
rateMatched = nrRateMatchPolar(in,K,E);

%
% Perform rate recovery of the rate-matched data and information block of 56 bits. The length of the rate-recovered output, N, is the same as the length of the original polar encoded message.

rateRecovered = nrRateRecoverPolar(rateMatched,K,N);

% Verify that the rate recovered output is identical to the original polar encoded input in.

isequal(rateRecovered,in)

% Copyright 2018 The MathWorks, Inc.