MATLAB Code
clc;
clear all;
close all;
snr = 0:2:16;
for i = 1:length(snr)
rng(10)
M = 8; % M = 2, 4, 8, 16, 32, etc.
N_Bits = 2520;
Phase = 0;
data_info_bit = randi([0,1],N_Bits,1);
data_temp = bi2de(reshape(data_info_bit,N_Bits/log2(M),log2(M)));
modData = pskmod(data_temp,M,Phase);
rxData2 = awgn(modData, snr(i));
Received_info = pskdemod(rxData2,M,Phase);
Received_info2 = de2bi(Received_info);
Received_info2 = [Received_info2(:,1)' Received_info2(:,2)' Received_info2(:,3)']
errors(i) = [(sum(xor(data_info_bit', Received_info2)))]
err_ber_fram(i) = errors(i)/length(Received_info2)
end
semilogy(snr, err_ber_fram,'-*','LineWidth',2);
title(sprintf('8-PSK'))
ylabel('BER'); xlabel('SNR in dB');grid on
clear all;
close all;
snr = 0:2:16;
for i = 1:length(snr)
rng(10)
M = 8; % M = 2, 4, 8, 16, 32, etc.
N_Bits = 2520;
Phase = 0;
data_info_bit = randi([0,1],N_Bits,1);
data_temp = bi2de(reshape(data_info_bit,N_Bits/log2(M),log2(M)));
modData = pskmod(data_temp,M,Phase);
rxData2 = awgn(modData, snr(i));
Received_info = pskdemod(rxData2,M,Phase);
Received_info2 = de2bi(Received_info);
Received_info2 = [Received_info2(:,1)' Received_info2(:,2)' Received_info2(:,3)']
errors(i) = [(sum(xor(data_info_bit', Received_info2)))]
err_ber_fram(i) = errors(i)/length(Received_info2)
end
semilogy(snr, err_ber_fram,'-*','LineWidth',2);
title(sprintf('8-PSK'))
ylabel('BER'); xlabel('SNR in dB');grid on
Read more about
[1] MATLAB Code for BER vs SNR for m-ary QAM, m-ary PSK, QPSK, BPSK ...
[2] MATLAB Code for BER vs SNR for QAM
[3] MATLAB Code for BER vs SNR for ASK, FSK, and PSK