资源描述
单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,2015/4/14,#,5.Obtain simulated BER results for Gray-coded QPSK and 8-PSK by creating a MATLABTM program.Run simulations for Eb/N0 in the range from 0 to 15dB.In which region does the nearest neighbor union bound on BER(see Problem 3)appear to be tight?,snrstart_dB=0;%Start Eb/N0 dB,snrstop_dB=15;%Stop Eb/N0 dB,snrdelta_dB=0.5;%Step size dB,samples=1e6;%Number of samples per Eb/N0 point,%Results(estimated bit error probabilities)result_antip=;result_QPSK=;result_8PSK=;,%Start a loop over the specified Eb/N0 values.for snr_dB=snrstart_dB:snrdelta_dB:snrstop_dB,%Print out current SNR.snr_dB,%Non-dB Eb/N0 snr=10(snr_dB/10);,%Assume that the same symbol is transmitted all the time.%Note that this is not always a valid assumption.,%-%First,binary antipodal signalling:,%Create zero mean Gaussian noise variables with unit variance.noise=randn(1,samples);,%snr=Eb/N0%var=N0/2=1%=N0=2%=Eb=snr*2%Detection threshold=sqrt(Eb),%If a(zero mean)noise sample is larger than sqrt(Eb),%a wrong decision is made.,%How many errors?error_vector=noise sqrt(snr*2);error_antip=sum(error_vector);,%Store results.result_antip=result_antip error_antip/samples;,%-%Coherent Gray coded QPSK signalling:%Note:two bits per symbol.,%snr=Eb/N0%var=N0/2=1(on both I and Q channels)%=N0=2%=Eb=snr*2%Es=2*Eb=Es=4*snr,%A correct decision is made if the constellation point angle%is within pi/4 and-pi/4.,%Create the transmitted signal(at sqrt(Es).t=sqrt(4*snr);,%Create the I and Q noise samples(zero mean,unit variance).noiseI=randn(1,samples);noiseQ=randn(1,samples);,%The received signals:r=t+noiseI+noiseQ*i;,%Angles for all samples:phi=angle(r);,%How many errors?,%One bit error:error_vector=phi pi/4,%Two bit errors:error_vector=phi 3*pi/4|phi N0=2%=Eb=snr*2%Es=3*Eb=Es=6*snr,%A correct decision is made if constellation point angle is%within pi/8 and-pi/8.Calculate distances to all signal%alternatives.,%Create signal alternatives.s=sqrt(6*snr)*exp(0:pi/4:7*pi/4*i);,%Create the transmitted signal.t=sqrt(6*snr);,%Create the I and Q noise samples(zero mean,unit variance).noiseI=randn(1,samples);noiseQ=randn(1,samples);,%The received signals:r=t+noiseI+noiseQ*i;,%Squared distances to all signal alternatives.%How many errors?,%Difference vector to signal alternative i:r-s(i),diff=;diff=diff;abs(r-s(1);diff=diff;abs(r-s(2);diff=diff;abs(r-s(3);diff=diff;abs(r-s(4);diff=diff;abs(r-s(5);diff=diff;abs(r-s(6);diff=diff;abs(r-s(7);diff=diff;abs(r-s(8);,%Get the indices of the signal alternatives with the minimum%(squared)distance for each sample.MinVal,Index=min(diff);,%One bit errors:error_vector=Index=2;%s(2)error_8PSK=sum(error_vector);error_vector=Index=6;%s(6)error_8PSK=error_8PSK+sum(error_vector);error_vector=Index=8;%s(8)error_8PSK=error_8PSK+sum(error_vector);,%Two bit errors:error_vector=Index=3;%s(3)error_8PSK=error_8PSK+2*sum(error_vector);error_vector=Index=5;%s(5)error_8PSK=error_8PSK+2*sum(error_vector);error_vector=Index=7;%s(7)error_8PSK=error_8PSK+2*sum(error_vector);,%Three bit errors:error_vector=Index=4;%s(4)error_8PSK=error_8PSK+3*sum(error_vector);,%Store results(three bits per sample).result_8PSK=result_8PSK error_8PSK/(samples*3);,end,%The Eb/N0 values:snr_dB=snrstart_dB:snrdelta_dB:snrstop_dB;,%Plot the results.figure;semilogy(snr_dB,Q(sqrt(2*10.(snr_dB/10),-);hold on;semilogy(snr_dB,result_antip,+);semilogy(snr_dB,result_QPSK,o);semilogy(snr_dB,2/3*Q(sqrt(6*10.(snr_dB/10)*sin(pi/8),:);semilogy(snr_dB,result_8PSK,d);ylabel(BER);xlabel(E_b/N_0 dB);legend(Exact BPSK and QPSK,Sim BPSK,Sim QPSK,.NNUB 8-PSK,Sim 8-PSK);,Figure Exact and simulated BER for BPSK and QPSK.Nearest neighbor union bound(NNUB)BER and simulated BER for 8-PSK.,It can be seen in Figure,that thestatistics get weaker as the Eb/N0 is increased since fewer and fewer error events occur.It is however hard to determine in which region the union bound appears to be tight for 8-PSK.,
展开阅读全文