%% Display Uplink Hopping PRB Allocation
% Display the PRB allocations associated with the sequence of subframes in a frame for an uplink resource allocation with hopping.
% Configure a type 1 uplink resource allocation that has type 0 hopping and slot and subframe hopping.

enbue = struct('NDLRB',50,'NCellID',0);
dcistr = lteDCI(enbue,struct('DCIFormat','Format0','AllocationType',0,...
    'FreqHopping',1));
dcistr.Allocation.HoppingBits = 0;
dcistr.Allocation.RIV = 110;
enbue.PUSCHHopping = 'InterAndIntra';
enbue.MacTxNumber = 0;
enbue.NSubbands = 1;
enbue.PUSCHHoppingOffset = 10;

% Display an image of the PRBs used in each slot of each subframe in a frame.
% Create a subframeslots matrix full of zeros. There are 20 slots per frame, specifically two slots per subframe and ten subframes per frame.
% Loop through assigning a PRB set of indices for each subframe. Also assign a value in subframeslots for each occupied PRB index.

subframeslots = zeros(enbue.NDLRB,20);
for i = 0:9
    enbue.NSubframe = i;
    prbSet = lteDCIResourceAllocation(enbue,dcistr);
    prbSet = repmat(prbSet,1,2/size(prbSet,2));
    for s = 1:2
        subframeslots(prbSet(:,s)+1,2*i+s) = 20+s*20;
    end
end
imagesc(subframeslots)
axis xy
xlabel('Subframe Slots')
ylabel('PRB Indices')

% Observe from the image that the occupied PRB indices hops in odd and even slots.
% Copyright 2012 The MathWorks, Inc.