clc
clear all;
%close all;
%8PSK simulation
tx_num = 3*1e6; %%% tx_num = 1e6;
tx_8 = randint(tx_num,1);%%% tx_8 = randint(1,tx_num);
%tx_8 = randint(1,tx_num);% tx_8 = [0 0 0 1 1 0 1 1 0 1 1 1 1 0 0 1 1 0];
tx_num=length(tx_8);tx_8 = reshape(tx_8,tx_num,1);
Es = 1; Eb = Es/3;%in watts
Eb_dB = 10*log10(Eb);
SNR = (0:1:12);
%SNR = (0:1:20); SNR=10;
SNR_lin = 10.^(SNR / 10);
BER_8PSK = zeros(1,length(SNR));
%%%%%%%%%%%%%%%Uncoded QPSK%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MPSK = 8;
H = modem.pskmod('M',MPSK,'SymbolOrder','gray','InputType','bit'); %QPSK
modulation %%%H = modem.pskmod('M',MPSK,'SymbolOrder','gray')
tx_8PSK = modulate(H,tx_8);%8PSK modulate tx
for n = 1:length(SNR)
tx_Noise = awgn(tx_8PSK,SNR(n),Eb_dB);% Add Gaussian noise.
G =
modem.pskdemod('M',MPSK,'SymbolOrder','gray','OutputType','bit');%QPSK
Demodulation%%%G = modem.pskdemod('M',MPSK,'SymbolOrder','gray');
rx_8PSK = demodulate(G,tx_Noise);
BER_8PSK(1,n) = sum(tx_8 ~= rx_8PSK) ;
%[nErrors, BER_8PSK(1,n)] = biterr(tx_8,rx_8PSK);BER_8PSK(1,n) =
sum(tx_8 ~= rx_8PSK) ;
end
BER_8PSK = BER_8PSK / tx_num;
bit_err_theo = (1/3)*erfc(sqrt(3*SNR_lin).*sin(pi/(MPSK)));
%bit_err_theo = (2/3).*qfunc((sqrt(2*3*SNR_lin)).*sin(pi/(MPSK)));
%semilogy(SNR,BER_8PSK,'g');
figure(11)
semilogy(SNR,BER_8PSK,'-gp',SNR,bit_err_theo,'r');
grid on;
评论1