PHỤ LỤC Code Matlab % MATLAB script for Problem clear SNRindB1=0:1:12;SNRindB2=0:0.1:12; for i=1:length(SNRindB1), smld_err_prb(i)=mophong1(SNRindB1(i)); end; for i=1:length(SNRindB2), SNR=exp(SNRindB2(i)*log(10)/10); theo_err_prb(i)=Qfunct(sqrt(SNR)); end; function [p]=mophong1(snr_in_dB) E=1; SNR=exp(snr_in_dB*log(10)/10); sgma=E/sqrt(2*SNR); N=10000; for i=1:N, temp=rand; if (tempr1), decis=0; else decis=1; end; if (decis~=dsource(i)), numoferr=numoferr+1; end; end; p=numoferr/N; % MATLAB script for Problem clear SNRindB1=0:1:10; SNRindB2=0:1:10; for i=1:length(SNRindB1), smld_err_prb(i)=mophong2(SNRindB1(i)); end; for i=1:length(SNRindB2), SNR=exp(SNRindB2(i)*log(10)/10); theo_err_prb(i)=Qfunct(sqrt(2*SNR)); end; function [p]=mophong2(snr_in_dB) E=1; SNR=exp(snr_in_dB*log(10)/10); sgma=E/sqrt(2*SNR); N=10000; for i=1:N, temp=rand; if (temp(M-8)*d), decis=12; elseif (r>(M-10)*d), decis=11; elseif (r>(M-12)*d), decis=10; elseif (r>(M-14)*d), decis=9; elseif (r>(M-16)*d), decis=8; elseif (r>(M-18)*d), decis=7; elseif (r>(M-20)*d),decis=6; elseif (r>(M-22)*d), decis=5; elseif (r>(M-24)*d),decis=4; elseif (r>(M-26)*d), decis=3; elseif (r>(M-28)*d), decis=2; elseif (r>(M-30)*d), decis=1; else decis=0; end; if (decis~=dsource(i)), numoferr=numoferr+1; end; end; p=numoferr/N; % MATLAB script for Problem M=4; initial_snr=0; final_snr=10; snr_step=1; tolerance=1e-7;minus_inf=-20; plus_inf=20; snr_in_dB=initial_snr:snr_step:final_snr; SNRindB1=0:2:10; SNRindB2=5:0.1:20; for i=1:length(SNRindB1), smld_err_prb(i)=smldp510(SNRindB1(i)); end; for i=1:length(snr_in_dB), SNR_per_bit=exp(snr_in_dB(i)*log(10)/10); snr=10^(snr_in_dB(i)/10); theo_err_prb(i)=(2*(M-1)/M)*Qfunct(sqrt((6*log2(M)/(M^2-1))*SNR_per_bit)); end; function [p]=mophong6(snr_in_dB) M=4; E=1; SNR=exp(snr_in_dB*log(10)/10); sgma=sqrt(E^2/(4*SNR));N=10000; for i=1:N, temp=rand; if (temp