custMap = [0 2 4 6 7 5 3 1];
hMod = comm.PSKModulator(8,'BitInput',true,'SymbolMapping','Custom','CustomSymbolMapping',custMap);
hDemod = comm.PSKDemodulator(8,'BitOutput',true,'SymbolMapping','Custom','CustomSymbolMapping',custMap);
constellation(hMod)
hChan = comm.AWGNChannel('BitsPerSymbol',log2(8));
hErr = comm.ErrorRate;
ebnoVec = 0:10;
ber = zeros(size(ebnoVec));
for k = 1:length(ebnoVec)
reset(hErr)
errVec = [0 0 0];
hChan.EbNo = ebnoVec(k);
while errVec(2) < 200 && errVec(3) < 1e7
data = randi([0 1],4000,1);
modData = step(hMod,data);
rxSig = step(hChan,modData);
rxData = step(hDemod,rxSig);
errVec = step(hErr,data,rxData);
end
ber(k) = errVec(1);
end
berTheory = berawgn(ebnoVec,'psk',8,'nondiff');
figure
semilogy(ebnoVec,[ber; berTheory])
xlabel('Eb/No (dB)')
ylabel('BER')
grid
legend('Simulation','Theory','location','ne')