您好,欢迎访问三七文档
实验1:AWGN信道中BPSK调制系统的BER仿真计算%SimulationofbpskAWGNMax_SNR=10;N_trials=1000;N=200;Eb=1;ber_m=0;fortrial=1:1:N_trialstrialmsg=round(rand(1,N));%1,0sequences=1-msg.*2;%0--1,1--1n=randn(1,N)+j.*randn(1,N);%generateguasswhitenoiseber_v=[];forsnr_dB=1:2:Max_SNRsnr=10.^(snr_dB./10);%snr(db)--snr(decimal)N0=Eb./snr;sgma=sqrt(N0./2);y=sqrt(Eb).*s+sgma.*n;y1=sign(real(y));y2=(1-y1)./2;%1,0sequenceerror=sum(abs(msg-y2));%errorbitsber_snr=error./N;%berber_v=[ber_v,ber_snr];end%forsnrber_m=ber_m+ber_v;endber=ber_m./N_trials;ber_theory=[];forsnr_db=1:2:Max_SNRsnr=10.^(snr_db./10);snr_1=Qfunct(sqrt(2*snr));ber_theory=[ber_theory,snr_1];endi=1:2:Max_SNR;semilogy(i,ber,'-r',i,ber_theory,'*b');xlabel('E_b/N_0(dB)')ylabel('BER')legend('MonteCarlo','Theoretic')程序分析:做1000次试验,每次试验取200个抽样点,求出每次试验的误比特率,然后对1000次试验的误比特率取平均值,即得仿真误比特率ber,然后将此误比特率与理论值ber_theory进行比较。程序运行结果如图3所示。12345678910-510-410-310-210-1Eb/N0(dB)BERMonteCarloTheoretic图3bpskAWGN误比特率仿真结果与理论值比较结果分析:由图3可知,仿真结果与理论值基本相符,只是在信噪比较大时,仿真误码率与理论值存在误差,这是因为在高信噪比情况下,误比特率会呈下降趋势,若要仿真实际的误比特率,就需要进行更多次试验,而且每次试验取的抽样点数也应该增加。%SimulationofqpskAWGNN_trials=1000;N_number=100;N_snr=10;Es=1;BER_m=0;SER_m=0;fortrials=1:N_trials;trialss10=round(rand(1,N_number));S=(s10*2-1)./sqrt(2);S1=S(1:2:N_number);S2=S(2:2:N_number);Sc=S1+j.*S2;%generateqpsksignalniose=randn(1,N_number/2)+j.*randn(1,N_number/2);%generatenoiseSER_v=[];%SymbolerrorrateBER_v=[];%Biterrorrateforsnr_db=0:1:N_snr;sgma=(1/2)*sqrt(10.^(-snr_db./10));Y=Sc+sgma.*niose;Y_r=sign(real(Y))./sqrt(2);Y_i=sign(imag(Y))./sqrt(2);Y_bit=[];fork=1:length(Y_r);Y_bit=[Y_bit,[Y_r(k),Y_i(k)]];end;Y_symbol=Y_r+j*Y_i;X_b=S-Y_bit;X_s=Sc-Y_symbol;ber_snr=0;fork=1:N_numberifX_b(k)~=0;ber_snr=ber_snr+1;end;end;ser_snr=0;fork=1:N_number/2;ifX_s(k)~=0;ser_snr=ser_snr+1;end;end;BER_v=[BER_v,ber_snr./N_number];SER_v=[SER_v,ser_snr./(N_number./2)];end;%forSNRBER_m=BER_m+BER_v;SER_m=SER_m+SER_v;end%fortrialsBER=BER_m./N_trials;SER=SER_m./N_trials;BER_T=[];SER_T=[];forsnr_db=0:1:N_snr;snr=10.^(snr_db./10);BER_THEORY=Qfunct(sqrt(2.*snr));SER_THEORY=1-(1-(1/2).*erfc(sqrt(snr))).^2;BER_T=[BER_T,BER_THEORY];SER_T=[SER_T,SER_THEORY];end;figurei=0:1:N_snr;semilogy(i,BER,'-r',i,BER_T,'*b');legend('BER-simulation','BER-theory');xlabel('Eb/N0(db)');ylabel('BER');figurei=0:1:N_snr;semilogy(i,SER,'-g',i,SER_T,'*y');legend('SER-simulation','SER-theory');xlabel('E_b/N_0(db)');ylabel('SER');程序分析:与bpskAWGN类似,做1000次试验,每次试验取100个点,然后每两个点形成一个qpsk符号,首先计算仿真误比特率和误码率,然后与理论值进行比较。程序运行结果如图4和图5所示,其中图4是ber图,图5是ser图。01234567891010-610-510-410-310-210-1Eb/N0(db)BERBER-simulationBER-theory图4BER仿真结果与理论值结果分析:由图4和图5可知,在低信噪比的情况下,BER和SER的仿真结果与理论值完全相符,在高信噪比情况下,两者存在差异,这是因为随着信噪比的增加,误比特率和误码率也会增加,这就需要更多的试验次数和更多的抽样点数。将BER和SER仿真结果进行比较可知,在相同信噪比的情况下,BER比SER小,这是因为只要一个比特错,相应的qpsk符号就会出错,而一个qpsk要正确接收,就必须保证它的两个比特全部正确接收。01234567891010-610-510-410-310-210-1100Eb/N0(db)SERSER-simulationSER-theory图5SER仿真结果与理论值实验2:移动通信信道建模与仿真%SimulationOfJakesModelclearall;f_max=30;M=8;%#oflowfrequencyoscillators-1N=4*M+2;Ts=1.024e-04;sq=2/sqrt(N);sigma=1/sqrt(2);theta=0;%FixedPhasecount=0;t0=0.001;fort=0:Ts:0.5%Varyingtimecount=count+1g(count)=0;forn=1:M+1,ifn=Mc_q(count,n)=2*sigma*sin(pi*n/M);%Gainassociatedwithquadraturecomponentc_i(count,n)=2*sigma*cos(pi*n/M);%Gainassociatedwithinphasecomponentf_i(count,n)=f_max*cos(2*pi*n/N);%Discretedopplerfrequenciesofinphasecomponentf_q(count,n)=f_max*cos(2*pi*n/N);%Discretedopplerfrequenciesofquadraturecomponentelsec_i(count,n)=sqrt(2)*cos(pi/4);c_q(count,n)=sqrt(2)*sin(pi/4);f_i(count,n)=f_max;f_q(count,n)=f_max;end;%endifg_i(count,n)=c_i(count,n)*cos(2*pi*f_i(count,n)*(t-t0)+theta);%Inphasecomponentforoneoscillatorg_q(count,n)=c_q(count,n)*cos(2*pi*f_q(count,n)*(t-t0)+theta);%Quadraturecomponentforoneoscillatorend;%endntp(count)=sq*sum(g_i(count,1:M+1));%TotalInphasecomponenttp1(count)=sq*sum(g_q(count,1:M+1));%Totalquadraturecomponentend;%endcountnonagainenvelope=sqrt(tp.^2+tp1.^2);%rayleighenvelopermsenv=sqrt(sum(envelope.^2)/count);%rootmeansquareenvelpe[auto_i,lag_i]=xcorr(tp,'coeff');%Auto-correlationassociatedwithinphasecomponent[auto_q,lag_q]=xcorr(tp1,'coeff');%Auto-correlationassociatedwithquadraturecomponentlen=length(lag_i);[corrx2,lag2]=xcorr(tp,tp1,'coeff');%CrossCorrelationbetweeninphaseandquadraturecomponentsaa=-(len-1)/2:1:(len-1)/2;%totaldurationforlagbb=(len-2001)./2;%mid...pointsfordrawingfigurescc=bb+1:1:bb+2001;%forgettingthemid-valuesdd=-1000:1:1000;%_______________tdd=dd*Ts;z=2.*pi.*f_max*tdd;sigma0=1;T_bessel=sigma0.^2.*besselj(0,z);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%figure;plot(tdd,auto_i(cc),'-',tdd,T_bessel,'*');%in-phasexlabel('t(Second)');ylabel('Auto-correlation');legend('In-component')figure;plot(tdd,auto_q(cc),'-',tdd,T_bessel,'*');%quadraturexlabel('t(Second)');ylabel('Auto-correlation');legend('Q-component')figureco1=1:1000;semilogy(co1*Ts,envelope(1:1000));xlabel('t(Second)');ylabel('RayleighCoef.');%%__________________________________________length_r=length(envelope);%____________________________pdf_env=zeros(1,501);count=0;temp=round(100
本文标题:移动通信实验报告
链接地址:https://www.777doc.com/doc-8498693 .html