【正文】
******** data4=data411+data422。 %BPSK 解調(diào) demodata1=data4 0。 %誤碼率計(jì)算 noe2=sum(abs(data1demodata1))。 nod2=length(data1)。 noe=noe+noe2。 nod=nod+nod2。 end %結(jié)果輸出 ber1(snr_num) = noe/nod end。 %結(jié)尾 figure。 semilogy(snr_in_dB,ber1,39。O39。)。 hold on semilogy(snr_in_dB,*erfc(sqrt(2*10.^(snr_in_dB/10))/sqrt(2)),39。+39。)。 hold on semilogy(snr_in_dB,.*(1sqrt((10.^(snr_in_dB/10))./(10.^(snr_in_dB/10)+1))),39。39。)。 ylabel(39。BER39。)。 xlabel(39。E_b/N_0 [dB]39。)。 legend(39。simulation BPSK EGC L=239。,39。theory gngauss BPSK39。,39。theory reyleigh39。 )。 無線通信 matlab 仿真報(bào)告 4 注釋 snr_in_dB=0:15。 for k=1:length(snr_in_dB) k N=10000。 E=1。 SNR=10^(snr_in_dB(k)/10)。 sigma=E/sqrt(2*SNR)。 for i=1:N a=rand。 if(a) data(i)=1。 else data(i)=1。 end end numofber=0。 totolnumber=0。 while numofber1 totolnumber=totolnumber+1。 for i=1:N H1 =1/sqrt(2)*[rand + j*rand]。 %第一個(gè)瑞利信道 H2 =1/sqrt(2)*[rand + j*rand]。 %第二個(gè)瑞利信道 H=[H1。H2]。 y1=H(1)*data(i)+sigma*(rand + j*rand)。 %在第一個(gè)信道下計(jì)算數(shù)據(jù) y2=H(2)*data(i)+sigma*(rand + j*rand)。 %在第二個(gè)信道下計(jì)算數(shù)據(jù) y=[abs(y1),abs(y2)]。 s=max(y)。 %選擇其中最大的數(shù)據(jù) if (s==abs(y2)) s=y2/H2。 else s=y1/H1。 end data2=sign(real(s))。 if (data2~=data(i)) numofber=numofber+1。 %計(jì)算誤比特率 end end end 無線通信 matlab 仿真報(bào)告 5 p(k)=numofber/(N*totolnumber)。 %計(jì)算誤碼率 end figure。 semilogy(snr_in_dB,p,39。O39。)。 hold on semilogy(snr_in_dB,*erfc(sqrt(2*10.^(snr_in_dB/10))/sqrt(2)),39。+39。)。 hold on semilogy(snr_in_dB,.*(1sqrt((10.^(snr_in_dB/10))./(10.^(snr_in_dB/10)+1))),39。39。)。 ylabel(39。BER39。)。 xlabel(39。E_b/N_0 [dB]39。)。 legend(39。simulation BPSK SEL L=239。,39。theory gngauss BPSK39。,39。theory reyleigh39。)。 ( b)觀察信噪比變化 10dB,誤比特率變化多少? 0 5 1 0 1 51 0 1 61 0 1 41 0 1 21 0 1 01 0 81 0 61 0 41 0 21 00BEREb/ N0 [ d B ] s i m u l a t i o n B P S K M R C L = 2t h e o r y g n g a u s s B P S Kt h e o r y r e y l e i g h MRC 誤比特率變化: = 無線通信 matlab 仿真報(bào)告 6 0 5 1 0 1 51 0 1 61 0 1 41 0 1 21 0 1 01 0 81 0 61 0 41 0 21 00BEREb/ N0 [ d B ] s i m u l a t i o n B P S K E G C L = 2t h e o r y g n g a u s s B P S Kt h e o r y r e y l e i g h EGC 誤比特率變化: = 0 5 1 0 1 51 0 1 61 0 1 41 0 1 21 0 1 0 81 0 61 0 41 0 21 00BEREb/ N0 [ d B ] s i m u l a t i o n B P S K S E L L = 2t h e o r y g n g a u s s B P S Kt h e o r y r e y l e i g h SEL 誤比特率變化: = ( c)程序中給出的是 2 分集,將其換為 3 分集,觀察信噪比變化 10dB,誤比特率變化多少? 無線通信 matlab 仿真報(bào)告