%% Create PSSCH Symbols
% Create a codeword using the SL-SCH transport channel and encode the bits on the PSSCH.
% Initialize a UE settings structure. Specify the codeword length to use for the SL-SCH. Choose a length that is a multiple of 12 symbols for normal cyclic prefix and has 4 bits per symbol for 16-QAM modulation. Pick a standard number of resource blocks, such as 10.

ue = struct('CyclicPrefixSL','Normal');
ue.RV = 0;
ue.Modulation = '16QAM';
ue.NSAID = 255;
ue.NSubframePSSCH = 0;
ue.SidelinkMode = 'D2D';

codewordlength = 5760; % (12 symbols)(4 bps)(12 REperRB)(10 PRB)

%
% Create a codeword using the lteSLSCH function and encode the bits on the PSSCH. Plot the constellation to show the effects of the SC-FDMA precoding on the 16-QAM modulation symbols.

codeword = lteSLSCH(ue,codewordlength,zeros(100,1));
symbols = ltePSSCH(ue,codeword);

plot(symbols,'o')

% Copyright 2012 The MathWorks, Inc.