【正文】
function [y]=Qfunct(x) % [y]=Qfunct(x) % QFUNCT evaluates the Qfunction. % y = 1/sqrt(2*pi) * integral from x to inf of exp(t^2/2) dt. % y = (1/2) * erfc(x/sqrt(2)). y=(1/2)*erfc(x/sqrt(2))。 % a uniform random variable in (0,1) z=sgma*(sqrt(2*log(1/(1u))))。 elseif nargin == 1, sgma=m。 ps=numofsymbolerror/N。 end。 symbolerror=1。 decis2=0。angle(rr)=(pi/4)), decis1=0。 elseif (angle(rr)(pi/4)amp。 decis2=1。 end。 (dsource2(i)==1)), r=s01+n。 n(2)=gngauss(sgma)。 end。 dsource2(i)=0。 dsource2(i)=0。 s11=[1 0]。 % energy per symbol snr=10^(snr_in_dB/10)。概率 P39。,1)。,39。)。*39。 % theoretical biterror rate echo off 。 end。 for i=1:length(SNRindB1), [pb,ps]=cm_sm322(SNRindB1(i))。通過(guò)在 MATLAB 平臺(tái)上進(jìn)行 M 文件編程,增強(qiáng)系統(tǒng)分析與設(shè)計(jì)數(shù)字通信系統(tǒng)的技能,有效地提高 Matlab 的應(yīng)用能力。試驗(yàn)中用的是將 r向量與作為標(biāo)準(zhǔn)的 s向量作向量積后選取最大者的方法。 % signaltonoise ratio theo_err_prb(i)=Qfunct(sqrt(2*SNR))。 ps=numofsymbolerror/N。 end。 symbolerror=1。 ,最后對(duì)符號(hào)差錯(cuò)和比特差錯(cuò)計(jì)數(shù)。 elseif(angle(rr)(3*pi/4)amp。 decis2=1。angle(rr)=(3*pi/4)), decis1=1。 再求 出信號(hào)集 {ms }中選取其相位最接近 r? 的信號(hào),通過(guò)求 相位角 angle 函數(shù)代替 actan函數(shù) : if (angle(rr)(3*pi/4)amp。 方法二: 根據(jù)設(shè)計(jì)要求,用另一種檢測(cè)器。 decis2=1。 decis2=1。 % The decision on the ith symbol is made next. c_max=max([c00 c01 c10 c11])。所以《現(xiàn)代通信系統(tǒng) matlab版 (第二版 )》例 M文件中一段程序是: c00=dot(r,s00)。 else r=s11+n。 elseif ((dsource1(i)==0) amp。 檢測(cè)器觀察到接收信號(hào)向量 r=Sm+n, 由 ? ? ( ) ( )( ) ( ) c o s ( 2 ) ( ) s in ( 2 )mm c c s cr t u t n tu t n t f t n t f t????? ? ? 程序: for i=1:N, % The received signal at the detector, for the ith symbol, is: n(1)=gngauss(sgma)。 end。 6 dsource2(i)=0。 dsource2(i)=0。 2. 為了完成這個(gè)任務(wù),利用一個(gè)隨機(jī)數(shù)列發(fā)生器,它會(huì)產(chǎn)生( 0,1)范圍內(nèi)的均勻隨機(jī)數(shù)。 % noise variance % the signal mapping s00=[1 0]。 5 五、 調(diào)制與測(cè)試 1. 先產(chǎn)生一個(gè) 4種符號(hào)( 2 比特)的序列,將它映射到相應(yīng)的 4 相信號(hào)點(diǎn),如圖中 M=4 的情況所示 程序: N=10000。對(duì) MP 的一種好的近似式是 0022 si n22 si nsMbPQ NMkQNM? ?? ??????????????? 式中 2logkM? 比特 /符號(hào)。據(jù)此,得到相關(guān)準(zhǔn)則為 ( , )mmC r s r s??, m=0,1,…, M1 由于全部信號(hào)都 具有相等的能量,因此,對(duì)數(shù)字相位調(diào)制一種等效的檢測(cè)器標(biāo)準(zhǔn)是計(jì)算接收信號(hào)向量 r=(cr ,sr )的相位為 arctan sr crr? ? 并從信號(hào)集 { ms }中選取其相位最接近 r? 的信號(hào)。 圖一 從 AWGN信道中,在一個(gè)信號(hào)區(qū)間內(nèi)接收到的帶寬信號(hào)可以表示為 ? ? ( ) ( )( ) ( ) c o s ( 2 ) ( ) s in ( 2 )mm c c s cr t u t n tu t n t f t n t f t????? ? ? 這里 ()t和