%% Decode HARQ-ACK Channel
% Show the block decoding of 3 coded HARQ-ACK information bits.
% Create input and initialize channel structure. Encode bits and turn logical bits into soft data compatible with log-likelihood ratio check. Use pskmod with an initial phase offset of \pi to align mapping with LTE codebook.
% Perform HARQ-ACK bit encoding and modulation.

in = [1;0;1];
chs = struct('Modulation','QPSK','QdACK',2,'OACK',length(in));

encodedBits = lteACKEncode(chs,in);
encodedBits = pskmod(double(encodedBits),2,pi());

%
% Pass transmitted encoded bits through an AWGN channel with a 20 dB signal-to-noise ratio. Show a scatterplot of the noisy received HARQ-ACK softbits.

rxBits = awgn(encodedBits,20);
scatterplot(rxBits)

%
% Decode the received softbits. Compare the decoded bits with the input bits to show the bits have been recovered with no error.

decodedBits = lteACKDecode(chs,rxBits)
isequal(in,decodedBits)

% Copyright 2012 The MathWorks, Inc.