symMap = [11 10 14 15 9 8 12 13 1 0 4 5 3 2 6 7];
sym = qammod(symMap(1:M)', M, symMap, 'UnitAveragePower', true);
bitTable = int2bit(symMap, bps)';
data = randi([0 1], nBits, 1);
modData = qammod(data, M, symMap, 'InputType', 'bit', 'UnitAveragePower', true);
modData = reshape(modData, [], 2);
H = randn(2, 2) + 1i * randn(2, 2);
awgnChan = comm.AWGNChannel('EbNo', ebno, 'BitsPerSymbol', bps);
sphDec = comm.SphereDecoder('Constellation', sym, 'BitTable', bitTable, 'DecisionType', 'Hard');
pathgains = repmat(permute(H', [3, 4, 1, 2]), NS, 1, 1, 1);
decodedData = sphDec(rxSig', squeeze(pathgains));
dataOut = double(decodedData(:));
berRate = comm.ErrorRate;
errorStats = berRate(data, dataOut);
disp(['Bit Error Rate: ', num2str(errorStats(1))]);
disp(['Number of Errors: ', num2str(errorStats(2))]);