移动通信实验报告.docx
《移动通信实验报告.docx》由会员分享,可在线阅读,更多相关《移动通信实验报告.docx(24页珍藏版)》请在冰豆网上搜索。
移动通信实验报告
实验1:
AWGN信道中BPSK调制系统的BER仿真计算
%SimulationofbpskAWGN
Max_SNR=10;
N_trials=1000;
N=200;
Eb=1;
ber_m=0;
fortrial=1:
1:
N_trials
trial
msg=round(rand(1,N));%1,0sequence
s=1-msg.*2;%0-->1,1-->1
n=randn(1,N)+j.*randn(1,N);%generateguasswhitenoise
ber_v=[];
forsnr_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,0sequence
error=sum(abs(msg-y2));%errorbits
ber_snr=error./N;%ber
ber_v=[ber_v,ber_snr];
end%forsnr
ber_m=ber_m+ber_v;
end
ber=ber_m./N_trials;
ber_theory=[];
forsnr_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('MonteCarlo','Theoretic')
程序分析:
做1000次试验,每次试验取200个抽样点,求出每次试验的误比特率,然后对1000次试验的误比特率取平均值,即得仿真误比特率ber,然后将此误比特率与理论值ber_theory进行比较。
程序运行结果如图3所示。
图3bpskAWGN误比特率仿真结果与理论值比较
结果分析:
由图3可知,仿真结果与理论值基本相符,只是在信噪比较大时,仿真误码率与理论值存在误差,这是因为在高信噪比情况下,误比特率会呈下降趋势,若要仿真实际的误比特率,就需要进行更多次试验,而且每次试验取的抽样点数也应该增加。
%SimulationofqpskAWGN
N_trials=1000;
N_number=100;
N_snr=10;
Es=1;
BER_m=0;
SER_m=0;
fortrials=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;%generateqpsksignal
niose=randn(1,N_number/2)+j.*randn(1,N_number/2);%generatenoise
SER_v=[];%Symbolerrorrate
BER_v=[];%Biterrorrate
forsnr_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_number
ifX_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;%forSNR
BER_m=BER_m+BER_v;
SER_m=SER_m+SER_v;
end%fortrials
BER=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;
figure
i=0:
1:
N_snr;
semilogy(i,BER,'-r',i,BER_T,'*b');
legend('BER-simulation','BER-theory');
xlabel('Eb/N0(db)');
ylabel('BER');
figure
i=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图。
图4BER仿真结果与理论值
结果分析:
由图4和图5可知,在低信噪比的情况下,BER和SER的仿真结果与理论值完全相符,在高信噪比情况下,两者存在差异,这是因为随着信噪比的增加,误比特率和误码率也会增加,这就需要更多的试验次数和更多的抽样点数。
将BER和SER仿真结果进行比较可知,在相同信噪比的情况下,BER比SER小,这是因为只要一个比特错,相应的qpsk符号就会出错,而一个qpsk要正确接收,就必须保证它的两个比特全部正确接收。
图5SER仿真结果与理论值
实验2:
移动通信信道建模与仿真
%SimulationOfJakesModel
clearall;
f_max=30;
M=8;%#oflowfrequencyoscillators-1
N=4*M+2;
Ts=1.024e-04;
sq=2/sqrt(N);
sigma=1/sqrt
(2);
theta=0;%FixedPhase
count=0;
t0=0.001;
fort=0:
Ts:
0.5%Varyingtime
count=count+1
g(count)=0;
forn=1:
M+1,
ifn<=M
c_q(count,n)=2*sigma*sin(pi*n/M);%Gainassociatedwithquadraturecomponent
c_i(count,n)=2*sigma*cos(pi*n/M);%Gainassociatedwithinphasecomponent
f_i(count,n)=f_max*cos(2*pi*n/N);%Discretedopplerfrequenciesofinphasecomponent
f_q(count,n)=f_max*cos(2*pi*n/N);%Discretedopplerfrequenciesofquadraturecomponent
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;%endif
g_i(count,n)=c_i(count,n)*cos(2*pi*f_i(count,n)*(t-t0)+theta);%Inphasecomponentforoneoscillator
g_q(count,n)=c_q(count,n)*cos(2*pi*f_q(count,n)*(t-t0)+theta);%Quadraturecomponentforoneoscillator
end;%endn
tp(count)=sq*sum(g_i(count,1:
M+1));%TotalInphasecomponent
tp1(count)=sq*sum(g_q(count,1:
M+1));%Totalquadraturecomponent
end;%endcountnonagain
envelope=sqrt(tp.^2+tp1.^2);%rayleighenvelope
rmsenv=sqrt(sum(envelope.^2)/count);%rootmeansquareenvelpe
[auto_i,lag_i]=xcorr(tp,'coeff');%Auto-correlationassociatedwithinphasecomponent
[auto_q,lag_q]=xcorr(tp1,'coeff');%Auto-correlationassociatedwithquadraturecomponent
len=length(lag_i);
[corrx2,lag2]=xcorr(tp,tp1,'coeff');%CrossCorrelationbetweeninphaseandquadraturecomponents
aa=-(len-1)/2:
1:
(len-1)/2;%totaldurationforlag
bb=(len-2001)./2;%mid...pointsfordrawingfigures
cc=bb+1:
1:
bb+2001;%forgettingthemid-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')
figure
co1=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.*envelope);
fork=1:
length_r
iftemp(k)<=500
count=count+1;
pdf_env(1,temp(k)+1)=pdf_env(1,temp(k)+1)+1;
end
end
count
pdf_env=pdf_env./count./0.01;%simulationrayleighpdf
sgma2=0.5;
x=[0:
0.01:
5];
pdf_theory=(x./sgma2).*exp(-1.*x.^2./(2.*sgma2));%theoryrayleighpdf
figure
plot(x,pdf_env,'-',x,pdf_theory,'*');
legend('Simulated','Theoretic');
xlabel('r');
ylabel('PDFofr');
程序分析:
首先选定jake模型得到参数M=8、N=4*M+2,然后计算各路的同相与正交分量的增益和多普勒频率,以及它们的表达式,该程序假设各路的延时相等,均为t0=0.001,各路相位均为0。
然后分别求同相分量和正交分量的自相关和互相关,分别作图,并分别与理论值相比较。
接着作出瑞利衰落系数图形,最后作出仿真的和理论的瑞利分布的概率密度函数,并进行比较。
程序运行结果如图6-图9所示。
图6同相分量的自相关仿真图形和理论图形
图7正交分量的自相关仿真图形和理论图形
图8瑞利衰落系数图形
图9瑞利分布概率密度函数仿真图形和理论图形
结果分析:
图6和图7的自相关和互相关函数图形仿真结果与理论结果大致相同,说明jake模型很好地分离出了接收信号同相分量和正交分量,图8是瑞利衰落系数的时域图形,图9中瑞利分布概率密度函数的仿真结果的大致变化趋势与理论值相同,只不过在概率密度较大的区域两者有较大差异,这是因为抽样点数太少,无法满足理论计算的要求,而且jake模型的M、N取值也会影响概率密度函数图形的仿真结果。
实验3:
CDMA通信仿真
%generaterayleighparameter
functionrayleigh_parameter=rayleigh_init_med(N,lambda,Ts)
globalspeed
%globalrayleigh_parameter
fmax=speed/3.6/lambda;
d_n1=N;
d_n2=N-1;
c1=sqrt(2*(asin((1:
d_n1)/d_n1)-asin((0:
d_n1-1)/d_n1))/pi);%varianceofu0(t)=1/2
f10=fmax*(2*(1:
d_n1)-1)/2/d_n1;
c2=sqrt(2*(asin((1:
d_n2)/d_n2)-asin((0:
d_n2-1)/d_n2))/pi);
f20=fmax*(2*(1:
d_n2)-1)/2/d_n2;
SamplingInterval=1;%case1,SamplingInterval=(1/8)chip;
%case2,16chips.
ifspeed~=0
f1=f10*2*pi*Ts;%Ts=12.5*10^(-6);%12.5us=16/1.28Mhz,i.e.16chips
f2=f20*2*pi*Ts;
else%speed==0
error('speed=0')
end
deltaN=d_n1-d_n2;
rayleigh_parameter=zeros(4,N);
rayleigh_parameter=[f1;c1;f2,zeros(1,deltaN);c2,zeros(1,deltaN)];
%generateRayleighenvelope
functionenvelop=rayleigh_fading(path,rayleigh_parameter,N_values)
globalspeed
frame=1;%system_clock
(2);%framenumber
TS=1;%system_clock(3);%TSnumber
d_n1=25;%thedefaultvalue:
d_n1=d_n2+1
d_n2=24;
f1=rayleigh_parameter(1,1:
d_n1);
c1=rayleigh_parameter(2,1:
d_n1);
f2=rayleigh_parameter(3,1:
d_n2);
c2=rayleigh_parameter(4,1:
d_n2);
cita1=rand(1,d_n1).*pi;
%cita2=condition_rayleigh(path,(d_n1+1):
(d_n1+d_n2),k_user);
cita2=rand(1,d_n2).*pi;
ifspeed~=0
d_t=0:
1:
N_values-1;%0.1s./2,(d_t)=57for1timeslot
M=length(d_t);
temp1=zeros(1,M);
temp2=zeros(1,M);
temp=zeros(1,M);
ford_t=0:
N_values-1
forloop=1:
d_n1
temp1=temp1+c1(loop)*cos(f1(loop)*d_t+cita1(loop));
end
forloop=1:
d_n2
temp2=temp2+c2(loop)*cos(f2(loop)*d_t+cita2(loop));
end
envelop=temp1+j*temp2;
end
end
%thisistoproduceapseudorandomsequence
%N=input('thelengthofthePNcode\n')
%k=input('thenumberofuser')
functionpseudonoise=pn_m(N,k)%producekN-longspreadsequence
n=log2(N+1);
%N=15,31%thenumberofworkunit
%n=4,5
forp=1:
k
a=zeros(1,n);
fori1=1:
p
a(i1)=1;
end
%ifp=1,a
(1)=1
%ifp=2,a
(1)=1,a
(2)=1
%.....
fori2=1:
N
pseudonoise(p,i2)=a
(1);%forp-thuser
m=xor(a
(1),a(n-1));
fori3=1:
n-1
a(i3)=a(i3+1);
end
a(n)=m;
end
fori=1:
N
pseudonoise(p,i)=pseudonoise(p,i)*2-1;%convert0,1to-1,1
end
end
%mainfile1:
ssbpskAWGN.m
N_Trials=1000;
N_number=100;
N_snr=10;;
Q=15;
E_M=[];
fortrials=1:
N_Trials
trials
noise=randn(1,Q*N_number)+j.*randn(1,Q*N_number);
s10=round(rand(1,N_number));%message
ss=s10*2-1;%0-->-1,1-->1
%pn01=round(rand(1,Q));
pn=pn_m(15,1)./sqrt(15);%pn:
1by15matrix
%pn=(pn01.*2-1)./sqrt(Q);
s=kron(ss,pn);%s:
1by1500matrix
sgma=1;
Error_v=[];
forsnr_db=0:
1:
N_snr
snr=10.^(snr_db./10);
N0=2*sgma.^2;
Eb=snr.*N0;
yy=sqrt(Eb)*s+noise;
Y_M=[];
fork=1:
N_number
ym=yy(1,(k-1)*Q+1:
k*Q);%Getyy'severy15points
Y_M=[Y_M;ym];%Y_M:
100by15matrix
end
ys=Y_M*pn.';%ys:
100by1matrix
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=[];
forsnr_db=0:
1:
N_snr
snr=10.^(snr_db./10);
BER_THEROY=Qfunct(sqrt(2.*snr));
BER_T=[BER_T,BER_THEROY];
end
lpa=1
i=0:
1:
N_snr;
semilogy(i,BER,'-r',i,BER_T,'*g');
xlabel('E_b/N_0(dB)')
ylabel('