用Matlab 编的BPSK及BER
clear all; close all; num=1000000; for SNR=0:14 %SNR(dB) data_bpsk=randsrc(1,num,[1,0]); % data=[1 -0 1 1 .....] 100000个 snr=1/(10^(SNR/10)); % n=1/snr noise=sqrt(snr/2)*(randn(1,num))/2; % receive=data_bpsk+noise; % receive=data+noise pe(SNR+1)=0; for (i=1:num) % 判决100000个data if (receive(i)>=0.5) % receive>=0 判决为1,否则-1 r_data(i)=1; % 判决后 接收到的DATA r_data else r_data(i)=0 ; end end pe(SNR+1)=(sum(abs((r_data-data_bpsk))))/num; %实验误码率 = 判决后 peb(SNR+1)=0.5*erfc(sqrt(10^(SNR/10))); % 理论误码率 end r=0:14; semilogy(r,peb,'b-v',r,pe,'m-x'); %对y取底为10对数? grid on; legend('Theoretical BER','Simulated BER');
暂无评论