function pktLen = commwman80216_2009_slotconcat(jSlot, n, slotLen)
%

%   Copyright 2013-2020 The MathWorks, Inc.

%------------------------------------------------------
% Slot concatenation rule (Table 492 & 493 in 8.4.9,2)
% jSlot: parameter dependent on the modulation and FEC rate;
% n = numSubChan;
%#codegen
pktLen = zeros(jSlot,1);
if n<=jSlot
    pktLen(n) = n*slotLen;  % 1 block of n slots
else
    k = floor(n/jSlot);
    m = mod(n,jSlot);
    if m == 0
        pktLen(jSlot) = k*jSlot*slotLen;  % (k-1) blocks of jSlot slots
    else
        a = ceil((m+jSlot)/2);
        b = floor((m+jSlot)/2);
        pktLen(jSlot) = (k-1)*jSlot*slotLen;       % (k-1) blocks of jSlot slots
        pktLen(a) = pktLen(a) + a*slotLen; % 1 block of ceil((m+jSlot)/2) slots
        pktLen(b) = pktLen(b) + b*slotLen; % 1 block of ceil((m+jSlot)/2) slots
        % Note: a==k, a==b, a!=k, a!=b cases are considered
    end
end
