%% Decode CellRefP from MIB
% This example shows use of ltePBCHDecode to decode the number of cell-specific reference ports from the Master Information Block (MIB):
% Initialize cell-wide configuration structure, enb, with RMC R.14. Generate MIB and the broadcast channel bits

enb = lteRMCDL('R.14');
mib = lteMIB(enb);
bchBits = lteBCH(enb,mib);

%
% lteBCH generates bits for a 40ms period, intended for 4 frames. Since PBCH is transmitted every frame, one quarter of these bits are encoded and transmitted each frame. In this example we encode the PBCH for a single frame. So, we only map and encode one quarter of the bchbits to PBCH. We then decode the PBCH symbols specifying cellrefp as an output. Looking at the number of cell-specific reference ports, cellrefp, we see it matches number of antenna ports specified in TS 36.101 Annex 3.3.2 for RMC R.14

quarterLen = length(bchBits)/4;
pbchSymbols = ltePBCH(enb,bchBits(1:quarterLen));
[bits,symbols,nfmod4,trblk,cellrefp] = ltePBCHDecode(enb,pbchSymbols);

cellrefp

% Copyright 2012 The MathWorks, Inc.