移动通信实验报告.doc_第1页
移动通信实验报告.doc_第2页
移动通信实验报告.doc_第3页
移动通信实验报告.doc_第4页
移动通信实验报告.doc_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实验1:AWGN信道中BPSK调制系统的BER仿真计算%Simulation of bpskAWGNMax_SNR=10;N_trials=1000;N=200;Eb=1;ber_m=0; for trial=1:1:N_trials trial msg=round(rand(1,N); % 1, 0 sequence s=1-msg.*2; %0-1, 1-1 n=randn(1,N)+j.*randn(1,N);%generate guass white noise ber_v=; for snr_dB=1:2:Max_SNR snr=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, 0 sequence error=sum(abs( msg- y2);%error bits ber_snr=error./N;%ber ber_v=ber_v,ber_snr; end %for snrber_m=ber_m+ber_v;endber=ber_m./N_trials; ber_theory=;for snr_db=1:2:Max_SNR snr=10.(snr_db./10); snr_1=Qfunct(sqrt(2*snr); ber_theory=ber_theory,snr_1;end i=1:2:Max_SNR;semilogy(i,ber,-r,i,ber_theory,*b);xlabel(E_b/N_0 (dB)ylabel(BER)legend(Monte Carlo, Theoretic)程序分析:做1000次试验,每次试验取200个抽样点,求出每次试验的误比特率,然后对1000次试验的误比特率取平均值,即得仿真误比特率ber,然后将此误比特率与理论值ber_theory进行比较。程序运行结果如图3所示。图3 bpskAWGN误比特率仿真结果与理论值比较结果分析:由图3可知,仿真结果与理论值基本相符,只是在信噪比较大时,仿真误码率与理论值存在误差,这是因为在高信噪比情况下,误比特率会呈下降趋势,若要仿真实际的误比特率,就需要进行更多次试验,而且每次试验取的抽样点数也应该增加。%Simulation of qpskAWGNN_trials=1000;N_number=100;N_snr=10;Es=1;BER_m=0;SER_m=0; for trials=1:N_trials; trials s10=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;%generate qpsk signal niose=randn(1,N_number/2)+j.*randn(1,N_number/2);%generate noise SER_v=;%Symbol error rate BER_v=;%Bit error rate for snr_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=; for k=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; for k=1:N_number if X_b(k)=0; ber_snr=ber_snr+1; end; end; ser_snr=0; for k=1:N_number/2; if X_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;%for SNRBER_m=BER_m+BER_v;SER_m=SER_m+SER_v; end % for trials BER=BER_m./N_trials;SER=SER_m./N_trials; BER_T=;SER_T=; for snr_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图。图4 BER仿真结果与理论值结果分析:由图4和图5可知,在低信噪比的情况下,BER和SER的仿真结果与理论值完全相符,在高信噪比情况下,两者存在差异,这是因为随着信噪比的增加,误比特率和误码率也会增加,这就需要更多的试验次数和更多的抽样点数。将BER和SER仿真结果进行比较可知,在相同信噪比的情况下,BER比SER小,这是因为只要一个比特错,相应的qpsk符号就会出错,而一个qpsk要正确接收,就必须保证它的两个比特全部正确接收。图5 SER仿真结果与理论值实验2:移动通信信道建模与仿真% Simulation Of Jakes Modelclear all;f_max = 30;M = 8; % # of low frequency oscillators - 1N = 4*M+2;Ts=1.024e-04;sq = 2/sqrt(N);sigma = 1/sqrt(2);theta = 0; % Fixed Phasecount = 0;t0=0.001; for t = 0:Ts:0.5 % Varying time count = count + 1 g(count) = 0; for n = 1 : M+1, if n = M c_q(count,n) = 2*sigma*sin(pi*n/M); % Gain associated with quadrature component c_i(count,n) = 2*sigma*cos(pi*n/M); % Gain associated with inphase component f_i(count,n) = f_max*cos(2*pi*n/N); % Discrete doppler frequencies of inphase component f_q(count,n) = f_max*cos(2*pi*n/N); % Discrete doppler frequencies of quadrature component else c_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; % end if g_i(count,n) = c_i(count,n)*cos(2*pi*f_i(count,n)*(t-t0) + theta); % Inphase component for one oscillator g_q(count,n) = c_q(count,n)*cos(2*pi*f_q(count,n)*(t-t0) + theta); % Quadrature component for one oscillator end; %end n tp(count) = sq*sum(g_i(count,1:M+1);% Total Inphase component tp1(count) = sq*sum(g_q(count,1:M+1);% Total quadrature component end; % end count no n again envelope=sqrt(tp.2+tp1.2);%rayleigh envelope rmsenv=sqrt(sum(envelope.2)/count);%root mean square envelpe auto_i,lag_i = xcorr(tp,coeff) ; % Auto-correlation associated with inphase component auto_q,lag_q = xcorr(tp1,coeff); % Auto-correlation associated with quadrature component len=length(lag_i); corrx2,lag2 = xcorr(tp,tp1,coeff);% Cross Correlation between inphase and quadrature components aa=-(len-1)/2:1:(len-1)/2;%total duration for lag bb=(len-2001)./2;%mid . points for drawing figures cc=bb+1:1:bb+2001;%for getting the mid-values dd=-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-phase xlabel(t(Second); ylabel(Auto-correlation); legend(In-component) figure; plot(tdd,auto_q(cc),-,tdd,T_bessel,*);%quadrature xlabel(t(Second); ylabel(Auto-correlation); legend(Q-component) figureco1=1:1000; semilogy(co1*Ts,envelope(1:1000);xlabel(t(Second);ylabel(Rayleigh Coef.);%_length_r=length(envelope); %_pdf_env=zeros(1,501); count=0;temp=round(100.*envelope);for k=1:length_r if temp(k)-1, 1-1 %pn01=round(rand(1,Q); pn=pn_m(15,1)./sqrt(15); %pn:1 by 15 matrix %pn=(pn01.*2-1)./sqrt(Q); s=kron(ss,pn); %s:1 by 1500 matrix sgma=1; Error_v= ; for snr_db=0:1:N_snr snr=10.(snr_db./10); N0=2*sgma.2; Eb=snr.*N0; yy=sqrt(Eb)*s+noise; Y_M= ; for k=1:N_number ym=yy(1,(k-1)*Q+1:k*Q); %Get yys every 15 points Y_M=Y_M;ym; %Y_M:100 by 15 matrix end ys=Y_M*pn.; %ys:100 by 1 matrix y=ys.; y_real=real(y); s_e=sign(y_real); s_e10=(s_e+1)./2; Error_snr=sum(abs(s10-s_e10); Error_v=Error_v,Error_snr./N_number; end E_M=E_M;Error_v ;end BER=mean(E_M); BER_T= ; for snr_db=0:1:N_snr snr=10.(snr_db./10); BER_THEROY=Qfunct(sqrt(2.*snr); BER_T=BER_T,BER_THEROY; end lpa=1i=0:1:N_snr;semilogy(i,BER,-r,i,BER_T ,*g);xlabel(E_b/N_0(dB)ylabel(BER)legend(Simulated, Theoretic);程序分析:做1000次试验,每次选取100个二进制信号,扩频增益Q为15,调用pn序列形成函数pn_m.m产生15为pn序列,然后调用kron函数求得信号与pn序列的乘积,从而求得发送扩频信号s,然后产生噪声,进而获得接收信号yy,接着将yy的每15个点组成一个向量ym并存入矩阵Y_M中,这样,Y_M中每一行就是接收到的加噪后的扩频信号,然后将每一行乘以pn序列(即扩频码)进行解扩,得到未扩频的信号。最后计算误比特率,并和理论值进行比较。程序运行结果如图10所示。图10 AWGN信道中bpsk扩频系统BER仿真结果与理论图形结果分析:由图10可知,在低信噪比情况下,BER的仿真结果与理论值完全吻合,当信噪比增大到9dB以上时,由于误码率大大减小,而程序中的取样点数和试验次数又没有相应增加,因此BER仿真值不能准确计算,从而未能在图10中显示出来。%main file2:ssbpskflat.mglobal speedMax_SNR=20;ber_m=;N_trial=1000;N=100;Q=8;k_user=2;for trial=1:N_trial trial %_ % the channel fs=20.*1e+6; Ts=1./fs; Fc=2.4*1e+9; c=3*10.8; lambda=c./Fc; speed=10; %km/h fd=(speed./3.6)./lambda; NN=25; rayleigh_parameter=rayleigh_init_med(NN,lambda,Ts); %generate rayleigh_parameter Envelope_M=; for k=1:k_user %fad=flat(N,fd,fs); fad= rayleigh_fading(path,rayleigh_parameter,N); %generate rayleigh envelop %rmsfad=sqrt(mean(abs(fad).2); envelope=kron(abs(fad),ones(1,Q); %convert matrix dimensions Envelope_M=Envelope_M;envelope;end pn=(2.*round(rand(k_user,Q)-1)./sqrt(Q); msg=round(rand(k_user,N); % 1, 0 sequence msg01=msg(1,:); ss=1-msg.*2 ; %0-1, 1- -1 %_ dataspread=; for k=1:k_user dk=ss(k,:); pnk=pn(k,:); dataspread=dataspread;kron(dk,pnk); end noise=randn(1,Q.*N)+j.*randn(1,Q.*N); ber_v=; sgma=1; for snr_db=1:2:Max_SNR snr1=10.(snr_db./10); N0=sgma.2.*2; Eb1=snr1.*N0; snr2_db=15; snr2=10.(snr2_db./10); Eb2=snr2.*N0; if k_user=3 error(only no more than 2 users) end if k_user=1 AM=sqrt(Eb1); else AM=sqrt(Eb1),sqrt(Eb2); end sig_r=AM*(Envelope_M.*dataspread); yspread=sig_r+sgma.*noise; DE_M=; for kk=1:N ykk=yspread(1,(kk-1).*Q+1:kk.*Q); DE_M=DE_M;ykk; end pn0=pn(1,:); de_data=DE_M*pn0.; y=sign(real(de_data.); y01=(1-y)./2; % 1, 0 sequence error=sum(abs( msg01- y01); ber_snr=error./(N); ber_v=ber_v,ber_snr; end %for snr ber_m=ber_m;ber_v;end %for trialber=mean(ber_m); ber_theory=; for snr_dB=1:2:Max_SNR; snr=10.(snr_dB./10);

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论