SNR_dB=0:1:30; %信噪比范围
LOOP=500;
%------------------------------------------
%--------------信源产生---------------------
%------------------------------------------
for i=1:length(SNR_dB)
snr=10^(SNR_dB(i)/10); %信噪比转换
sgma=sqrt(8/snr/3); %噪声方差
error0=0;
error1=0;
error2=0;
error3=0;
for a=1:LOOP
N=2560; %仿真序列长度
S=randsrc(1,N,[0,1]); %二进制序列信源 产生n个随机数
%-------------------------------------------
%------------有信道编码----------------------
%-------------------------------------------
S00=convolutionalcode(S);
%--------------QPSK调制---------------------
s=QPSK(S00);
s0=zeros(1,3*N/4); %将调制后的信息奇偶拆分成两个信息以进行MIMO发射
s1=zeros(1,3*N/4);
for b1=1:2:(3*N/2)
s0(ceil(b1/2))=s(b1);
s1(ceil(b1/2))=s(b1+1);
end
N1=size(s0,2);
%--------有信道编码(2发2收)-----------------
h0=sqrt(0.5).*(randn(1,N1)+1i.*randn(1,N1)); %设置信道冲激响应
h1=sqrt(0.5).*(randn(1,N1)+1i.*randn(1,N1));
h2=sqrt(0.5).*(randn(1,N1)+1i.*randn(1,N1));
h3=sqrt(0.5).*(randn(1,N1)+1i.*randn(1,N1));
%------接收到的信号(冲激响应与发送序列卷积)---
R0=h0.*s0+h1.*s1; %接收信号矢量(不含高斯噪声)
R1=-conj(s1).*h0+h1.*conj(s0); %移动通信P166
R2=h2.*s0+h3.*s1;
R3=-conj(s1).*h2+h3.*conj(s0);
%通过AWGN信道加入噪声后的冲击序列
r0=(R0+sgma.*(randn(1,N1)+1i*randn(1,N1)));%接收信号矢量(有噪声)
r1=(R1+sgma.*(randn(1,N1)+1i*randn(1,N1)));
r2=(R2+sgma.*(randn(1,N1)+1i*randn(1,N1)));
r3=(R3+sgma.*(randn(1,N1)+1i*randn(1,N1)));
s_0=conj(h0).*r0+h1.*conj(r1)+conj(h2).*r2+h3.*conj(r3);%STBC空时译码
s_1=conj(h1).*r0-h0.*conj(r1)+conj(h3).*r2-h2.*conj(r3);
for l0=1:3*N/4 %将接收到的信号合并
Y0(2*l0-1)=s_0(l0);
Y0(2*l0)=s_1(l0);
end
y0=DEQPSK(Y0); %QPSK解调
m0=viterbi(y0); %维特比译码
[n0,e0]=biterr(m0,S);%计算误比特率
error0=error0+n0;
%有信道编码2发1收
hr0=sqrt(0.5).*(randn(1,N1)+1i.*randn(1,N1)); %瑞利信道函数
hr1=sqrt(0.5).*(randn(1,N1)+1i.*randn(1,N1));
Rr0=hr0.*s0+hr1.*s1; %接收信号矢量(不含高斯噪声)
Rr1=-conj(s1).*hr0+hr1.*conj(s0);
rN0=(Rr0+sgma.*(randn(1,N1)+1i*randn(1,N1)));%接收信号矢量(含复高斯噪声)
rN1=(Rr1+sgma.*(randn(1,N1)+1i*randn(1,N1)));
sr_0=conj(hr0).*rN0+hr1.*conj(rN1);%STBC空时译码
sr_1=conj(hr1).*rN0-hr0.*conj(rN1);
for l1=1:3*N/4 %将接收到的信号合并
Y1(2*l1-1)=sr_0(l1);
Y1(2*l1)=sr_1(l1);
end
y1=DEQPSK(Y1); %QPSK解调
m1=viterbi(y1); %维特比译码
[n1,e1]=biterr(m1,S);%计算误比特率
error1=error1+n1;
%---------------------------
%无信道编码
%---------------------------
sn=QPSK(S); %QPSK调制
for b2=1:2:(N/2) %将调制后的信息奇偶拆分成两个信息以进行MIMO发射
sn0(ceil(b2/2))=sn(b2);
sn1(ceil(b2/2))=sn(b2+1);
end
N2=size(sn0,2);
%无信道编码(2发2收)
hn0=sqrt(0.5).*(randn(1,N2)+1i.*randn(1,N2)); %瑞利信道函数
hn1=sqrt(0.5).*(randn(1,N2)+1i.*randn(1,N2));
hn2=sqrt(0.5).*(randn(1,N2)+1i.*randn(1,N2));
hn3=sqrt(0.5).*(randn(1,N2)+1i.*randn(1,N2));
Rn0=hn0.*sn0+hn1.*sn1; %接收信号矢量(无噪声)
Rn1=-conj(sn1).*hn0+hn1.*conj(sn0);
Rn2=hn2.*sn0+hn3.*sn1;
Rn3=-conj(sn1).*hn2+hn3.*conj(sn0);
rn0=(Rn0+sgma.*(randn(1,N2)+1i*randn(1,N2))); %接收信号矢量(有噪声)
rn1=(Rn1+sgma.*(randn(1,N2)+1i*randn(1,N2)));
rn2=(Rn2+sgma.*(randn(1,N2)+1i*randn(1,N2)));
rn3=(Rn3+sgma.*(randn(1,N2)+1i*randn(1,N2)));
sn_0=conj(hn0).*rn0+hn1.*conj(rn1)+conj(hn2).*rn2+hn3.*conj(rn3);
sn_1=conj(hn1).*rn0-hn0.*conj(rn1)+conj(hn3).*rn2-hn2.*conj(rn3);
for l2=1:N/4 %将接收到的信号合并
Y2(2*l2-1)=sn_0(l2);
Y2(2*l2)=sn_1(l2);
end
y2=DEQPSK(Y2); %QPSK解调
y2=y2';
[n2,e2]=biterr(y2,S);%计算误比特率
error2=error2+n2;
%无信道编码(2发1收)
hN0=sqrt(0.5).*(randn(1,N2)+1i.*randn(1,N2)); %瑞利信道函数
hN1=sqrt(0.5).*(randn(1,N2)+1i.*randn(1,N2));
RN0=hN0.*sn0+hN1.*sn1; %发射序列与接收序列的卷积
RN1=-conj(sn1).*hN0+hN1.*conj(sn0);
rN0=(RN0+sgma.*(randn(1,N2)+1i*randn(1,N2))); %接收信号矢量(有噪声)
rN1=(RN1+sgma.*(randn(1,N2)+1i*randn(1,N2)));
sN_0=conj(hN0).*rN0+hN1.*conj(rN1);
sN_1=conj(hN1).*rN0-hN0.*conj(rN1);
for l3=1:N/4 %将接收到的信号合并
Y3(2*l3-1)=sN_0(l3);
Y3(2*l3)=sN_1(l3);
end
y3=DEQPSK(Y3); %QPSK解调
y3=y3';
[n3,e3]=biterr(y3,S);%计算误比特率
error3=error3+n3;
end
BER0(i)=error0/(LOOP*N);
BER1(i)=error1/(LOOP*N);
BER2(i)=error2/(LOOP*N);
BER3(i)=error3/(LOOP*N);
end
semilogy(SNR_dB,BER0,'r');
hold on;
semilogy(SNR_dB,BER1, 'b');
semilogy(SNR_dB,BER2,'g');
semilogy(SNR_dB,BER3,'k');
grid on;
legend('2Tx2R卷积信道编码','2Tx1R卷积信道编码','2Tx2R无信道编码','2Tx1R无信道编码');
xlabel('SNR/dB');
ylabel('BER');
- 1
- 2
前往页