MATLAB CODE:

clc;
clear all;
close all;
M = 16;

%channel modulation and demodulation————————————————————————
hMod = modem.pskmod(M);
hDemod = modem.pskdemod(hMod);
% Generate data stream—————————————————————————————————
tx = randint(10000,1,M);
% Modulate the data——————————————————————————————————–
txSig = modulate(hMod, tx);
% Compute error rate for different values of SNR————————————————————
EbNo = (-3:20); %defining SNR range (in dB)
k = log2(M);
SNR = EbNo+10*log10(k); % Range of SNR values, in dB(Because No = 2*noiseVariance^2,
BER = zeros(length(SNR), 1);
rx = zeros(length(tx),1);
for n = 1:length(SNR)
rxSig = awgn(txSig,SNR(n),’measured’); % Addition of  Gaussian noise.
rx = demodulate(hDemod, rxSig); % Demodulation at the receiver.
% Compute error rate—————————————————————————————————–
[nErrors, BER(n,1)] = biterr(tx,rx);
end
% Compute theoretical performance results, for comparison——————————————
BERtheory = berawgn(SNR,’psk’,M,’nondiff’);

%ploting————————————————————————————————————————
semilogy(EbNo,BERtheory,’b-‘,EbNo,BER,’r*’,EbNo,BER,’r’);grid on;hold on;
legend(‘Theoretical BER’,’Empirical BER’);
xlabel(‘Eb/No (dB)’); ylabel(‘BER’);
title(’16PSK Modulation in an AWGN channel’);

RESULTS: