Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
初级会员
注册日期: 2010-04-20
帖子: 1
声望力: 0 ![]() |
![]()
我编写了一个个差分空时分组码的MATLAB仿真程序,天线是两发一收,主要思路是在发送端先进性差分空时编码,进行差分空时译码,程序出来的应该是信噪比对应的误码率的曲线图,但是结果不对。这是我的毕业设计,由于时间问题,希望大家帮帮忙!在此先谢过了!
function pb=differential(snr_in_dB) N=1000; source=randint(1,N); x_ref=[1/sqrt(2),1/sqrt(2);-1/sqrt(2),1/sqrt(2)]; map_00=[1,0]; map_10=[0,1]; map_01=[0,-1]; map_11=[-1,0]; pole_1=[];pole_2=[]; for i=1:2:N, pole_1=[pole_1,source(i)]; pole_2=[pole_2,source(i+1)]; end numofbiterror=0; for i=1:N/2, if (pole_1(i)==0)&(pole_2(i)==0) r1=1;r2=0; elseif (pole_1(i)==0)&(pole_2(i)==1) r1=0;r2=-1; elseif (pole_1(i)==1)&(pole_2(i)==0) r1=0;r2=1; else r1=-1;r2=0; end sent_signal=[r1,r2]*(x_ref.'); next_sent_signal=[-conj(sent_signal(2)),conj(sent_signal(1))]; next_x_ref=[sent_signal.',next_sent_signal.']; %瑞利慢衰落信道H参数 H1=randn(1,1)/sqrt(2)+j*randn(1,1)/sqrt(2); H2=randn(1,1)/sqrt(2)+j*randn(1,1)/sqrt(2); sig = sqrt(1/(10^(snr_in_dB/10))); n1=sig * (randn(1,1) + j*randn(1,1)); n2=sig * (randn(1,1) + j*randn(1,1)); n3=sig * (randn(1,1) + j*randn(1,1)); n4=sig * (randn(1,1) + j*randn(1,1)); R1_signal=H1*x_ref(1,1)+H2*x_ref(2,1)+n1; R2_signal=-H1*x_ref(1,2)+H2*(-x_ref(2,2))+n2; R3_signal=H1*sent_signal(1)+H2*sent_signal(2)+n3; R4_signal=-H1*next_sent_signal(1)+H2*(-next_sent_signal(2))+n4; R1=R3_signal*conj(R1_signal)+conj(R4_signal)*R2_signal; R2=R3_signal*conj(R2_signal)-conj(R4_signal)*R1_signal; r=[R1,R2]; s00=sqrt((abs(R1-map_00(1)))^2+(abs(R2-map_00(2)))^2); s01=sqrt((abs(R1-map_01(1)))^2+(abs(R2-map_01(2)))^2); s10=sqrt((abs(R1-map_10(1)))^2+(abs(R2-map_10(2)))^2); s11=sqrt((abs(R1-map_11(1)))^2+(abs(R2-map_11(2)))^2); %s00=abs(r-map_00); %s01=abs(r-map_01); %s10=abs(r-map_10); %s11=abs(r-map_11); s_min=min([s00 s01 s10 s11]);%注意最小距离 if(s00==s_min), decis1=0;decis2=0; elseif (s01==s_min), decis1=0;decis2=1; elseif (s10==s_min), decis1=1;decis2=0; else decis1=1;decis2=1; end if (decis1~=pole_1(i)) numofbiterror=numofbiterror+1; end if (decis2~=pole_2(i)) numofbiterror=numofbiterror+1; end end pb=numofbiterror/N; |
![]() |
![]() |