This is my maiden post, will also write more ICT blog. Today for everyone presented MATLAB simulation BPSK modulation of the codes:
Clear ALL;CLC;
Snr_db=1:1:9;
snr=10.^ (SNR_DB./10);
Size=length (snr_db);
A=ones (1,size);% fixed a, variable sigma defined
Sigma=sqrt (1./(2*snr));%a=1
n=10000;
S=randi ([0,1],1,n);
s1=2*s-1;
S2=zeros (1,n);
N_errb=zeros (1,size);
For I=1:1:size
N=sigma (i). *RANDN (1,n);
Y=s1+n;
For J=1:1:n
If Y (j) >0
S2 (j) = 1;
Else Y (j) <=0
S2 (j) = 0;
End
End
For K=1:1:n
If S2 (k) ~=s (k)
N_ERRB (i) =N_ERRB (i) +1;
End
End
End
ber=n_errb./n;
T_ber=qfunc (sqrt (2*snr));
Semilogy (Snr_db,ber,snr_db,t_ber);
Legend (' Simulated BER ', ' theoretical ber ');
Hold on; Grid on;
If you have any questions about this code, you can call my email address: [email protected].
Next period for everyone to bring with MATLAB simulation QPSK modulation. Like can pay attention to me ~ Thank you.
Simulation of BPSK modulation with MATLAB