Contents

function [h, c] = generate_mbm_constellation(Nr, Nt, M)
%generateConstellation generates constellation points for LMIMO-MBM
% M number of points in constellation

Generate constituent vectors

R = log2(M);
Mt = 2^(R/Nt); % Number of constituent vectors per transmit unit
h = generate_constituent();

Forming constellation points from constituent vectors

Constellation points are formed using the superposition of constituent vectors:

$$\mathbf{c}(\mathbf{m}) = \sum_{n=1}^{N_t} \mathbf{h}^{n}(\mathbf{m}_n) $$

c = zeros(Nr, M);
for m = 1 : M
    d = dec2Base(m, Mt, Nt);
    for n = 1 : Nt
        c(:, m) = c(:, m) + h(:, d(n), n);
    end
end

Function to generate consitituent vectors

    function h = generate_constituent()
        %generateConstituent generates constituent vectors for LMIMO-MBM
        % 3D matrix holding constituent vectors
        h = sqrt(0.5) * (randn(Nr, Mt, Nt) + 1i * randn(Nr, Mt, Nt));
    end

Function to change base of a decimal number

    function yBase = dec2Base(D, B, nDigits)
        %dec2Base return the represntation of number D in base B
        % nDigits is number of digits in base B
        yBase = zeros(1, nDigits);
        D = D - 1;
        for iDigits = nDigits : -1 : 1
            yBase(1, nDigits - iDigits + 1) = floor(D /( B ^ (iDigits -1)));
            D = D - yBase(1,  nDigits - iDigits + 1) * B ^ (iDigits - 1);
        end
        yBase = yBase + 1;
    end
end