程序:碧悔
qr=0.2%探测效率
l=255*10^(-9)%波喊斗长
g=100%接收增悔渗正益
h=6.626*10^(-34)%普朗克常量
c=3*10^8%光速
R=10.^3%码速率
Pr=0.05%接收功率
% SNR=qr.*g.*Pr.*l./(2.*R.*h.*c)%信噪比
SNR=[0.0001:0.001:1]
BER=0.5.*erfc(sqrt(SNR/8))%误码率
semilogx(SNR,BER)
grid on
结果:
这样改:clc
clear
SNR_DB=0:1:12
sum=1000000
data= randsrc(sum,2,[0 1])
[a1,b1]=find(data(:,1)==0&data(:,2)==0)
message(a1)=-1-1i
[a2,b2]=find(data(:,1)==0&data(:,2)==1)
message(a2)=-1+1i
[a3,b3]=find(data(:,1)==1&data(:,2)==0)
message(a3)=1-1i
[a4,b4]=find(data(:,1)==1&data(:,2)==1)
message(a4)=1+1i
scatterplot(message)
title('B点信号的星座图')
A=1
Tb=1
Eb=A*A*Tb
P_signal=Eb/Tb
NO=Eb./(10.^(SNR_DB/10))
P_noise=P_signal*NO
sigma=sqrt(P_noise)
for Eb_NO_id=1:length(sigma)
noise1=sigma(Eb_NO_id)*randn(1,sum)
noise2=sigma(Eb_NO_id)*randn(1,sum)
receive=message+noise1+noise2*1i
%resum=0
%total=0
m1=find(angle(receive)<=pi/2&angle(receive)>0)
remessage(1,m1)=1+1i
redata(m1,1)=1
redata(m1,2)=1
m2= find( angle(receive)>pi/2&angle(receive)<=pi)
remessage(1,m2)=-1+1i
redata(m2,1)=0
redata(m2,2)=1
m3=find( angle(receive)>-pi&angle(receive)<=-pi/2)
remessage(1,m3)=-1-1i
redata(m3,1)=0
redata(m3,2)=0
m4=find( angle(receive)>-pi/2&angle(receive)<=0)
remessage(1,m4)=1-1i
redata(m4,1)=1
redata(m4,2)=0
[resum,ratio1]=symerr(data,redata)
pbit(Eb_NO_id)=resum/(sum*2)
[total,ratio2]=symerr(message,remessage)
pe(Eb_NO_id)=total/正迟sum
end
scatterplot(receive)
title('C点信号的星座图')
Pe=1-(1-1/2*erfc(sqrt(10.^(SNR_DB/10)/2))).^2
Pbit=1/2*erfc(sqrt(10.^(SNR_DB/10)/拦厅2))
figure(3)
semilogy(SNR_DB,pe,':s',SNR_DB,Pe,'-*',SNR_DB,pbit,'-o',SNR_DB,Pbit,':+')
legend('QPSK仿真误码率','QPSK理论误码率','QPSK仿真简清隐误比特率','QPSK理论误比特率')
xlabel('信噪比/dB')
ylabel('概率P')
grid on
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)