% 仿真五种(MRC,ZF,MMSE,ZF-SIC,MMSE-SIC) Vblast接收的检测性能,绘制误比特率~接收天线数曲线。
% 发端初始化===============================================================
% 发射天线数tx,接收天线数rx,发射矩阵长度L(帧长)
clear all;
clc;
tx=10;
rx_number=[20:20:200];
L=10000;
Modulation='QPSK';
EbN0=5;
B=30000;Ts=1/24300;
SNR=EbN0-10*log10(Ts*B);
% SNR=5;
% 信源A
A=randi([0,3],tx*L,1);
% 经过QPSK调制的V-Blast发射矩阵X
X1=reshape(A,tx,L);
X=zeros(tx,L);
for k=1:L
X(:,k)=pskmod(X1(:,k),4);
end
% 检测
% MRC======================================================================
disp('MRC');
berm=[];
for rx=rx_number
rx
% 快衰落Rayleigh信道H
H=sqrt(1/2)*(randn(rx,tx,L)+i*randn(rx,tx,L));
% 均值为0方差为1的高斯白噪声n
n=sqrt(1/2)*(randn(rx,L)+i*randn(rx,L));
% 未叠加噪声的接收信号R
R=zeros(rx,L);
for k=1:L
R(:,k)=sqrt(1/tx)*H(:,:,k)*X(:,k);
end
snr=10^(SNR/10);
R_noised=R+sqrt(1/snr)*n;
x=[];
% 逐时隙对接收符号矢量进行检测,合并得到一帧发射矩阵X的估计x
for t=1:L
r=R_noised(:,t);
HH=H(:,:,t);
G=HH';
y=G*r;
xtemp=zeros(tx,1);
for k=1:tx
if imag(y(k))<real(y(k)) && imag(y(k))>-real(y(k))
xtemp(k)=1;
elseif imag(y(k))>real(y(k)) && imag(y(k))>-real(y(k))
xtemp(k)=i;
elseif imag(y(k))>real(y(k)) && imag(y(k))<-real(y(k))
xtemp(k)=-1;
elseif imag(y(k))<real(y(k)) && imag(y(k))<-real(y(k))
xtemp(k)=-i;
end
end
x=[x,xtemp];
end
% 从x求A的估计a
x1=zeros(tx,L);
for k=1:L
x1(:,k)=pskdemod(x(:,k),4);
end
a=reshape(x1,tx*L,1);
% 比较A和a计算错值率temp_ber
[errbit,temp_ber]=biterr(A,a,2);
berm=[berm,temp_ber];
end
figure
semilogy(rx_number,berm,'*- g');
hold on
% ZF=======================================================================
disp('ZF');
berz=[];
for rx=rx_number
rx
% 快衰落Rayleigh信道H
H=sqrt(1/2)*(randn(rx,tx,L)+i*randn(rx,tx,L));
% 均值为0方差为1的高斯白噪声n
n=sqrt(1/2)*(randn(rx,L)+i*randn(rx,L));
% 未叠加噪声的接收信号R
R=zeros(rx,L);
for k=1:L
R(:,k)=sqrt(1/tx)*H(:,:,k)*X(:,k);
end
snr=10^(SNR/10);
R_noised=R+sqrt(1/snr)*n;
x=[];
% 逐时隙对接收符号矢量进行检测,合并得到一帧发射矩阵X的估计x
for t=1:L
r=R_noised(:,t);
HH=H(:,:,t);
G=pinv(HH);
y=G*r;
xtemp=zeros(tx,1);
for k=1:tx
if imag(y(k))<real(y(k)) && imag(y(k))>-real(y(k))
xtemp(k)=1;
elseif imag(y(k))>real(y(k)) && imag(y(k))>-real(y(k))
xtemp(k)=i;
elseif imag(y(k))>real(y(k)) && imag(y(k))<-real(y(k))
xtemp(k)=-1;
elseif imag(y(k))<real(y(k)) && imag(y(k))<-real(y(k))
xtemp(k)=-i;
end
end
x=[x,xtemp];
end
% 从x求A的估计a
x1=zeros(tx,L);
for k=1:L
x1(:,k)=pskdemod(x(:,k),4);
end
a=reshape(x1,tx*L,1);
% 比较A和a计算错值率temp_ber
[errbit,temp_ber]=biterr(A,a,2);
berz=[berz,temp_ber];
end
semilogy(rx_number,berz,'o- b');
% MMSE=====================================================================
disp('MMSE');
bermm=[];
for rx=rx_number
rx
% 快衰落Rayleigh信道H
H=sqrt(1/2)*(randn(rx,tx,L)+i*randn(rx,tx,L));
% 均值为0方差为1的高斯白噪声n
n=sqrt(1/2)*(randn(rx,L)+i*randn(rx,L));
% 未叠加噪声的接收信号R
R=zeros(rx,L);
for k=1:L
R(:,k)=sqrt(1/tx)*H(:,:,k)*X(:,k);
end
snr=10^(SNR/10);
R_noised=R+sqrt(1/snr)*n;
x=[];
% 逐时隙对接收符号矢量进行检测,合并得到一帧发射矩阵X的估计x
for t=1:L
r=R_noised(:,t);
HH=H(:,:,t);
G=inv(HH'*HH+(1/snr)*eye(tx))*HH';
y=G*r;
xtemp=zeros(tx,1);
for k=1:tx
if imag(y(k))<real(y(k)) && imag(y(k))>-real(y(k))
xtemp(k)=1;
elseif imag(y(k))>real(y(k)) && imag(y(k))>-real(y(k))
xtemp(k)=i;
elseif imag(y(k))>real(y(k)) && imag(y(k))<-real(y(k))
xtemp(k)=-1;
elseif imag(y(k))<real(y(k)) && imag(y(k))<-real(y(k))
xtemp(k)=-i;
end
end
x=[x,xtemp];
end
% 从x求A的估计a
x1=zeros(tx,L);
for k=1:L
x1(:,k)=pskdemod(x(:,k),4);
end
a=reshape(x1,tx*L,1);
% 比较A和a计算错值率temp_ber
[errbit,temp_ber]=biterr(A,a,2);
bermm=[bermm,temp_ber];
end
semilogy(rx_number,bermm,'o- r');
% ZF-SIC===================================================================
disp('ZF-SIC');
berzs=[];
for rx=rx_number
rx
% 快衰落Rayleigh信道H
H=sqrt(1/2)*(randn(rx,tx,L)+i*randn(rx,tx,L));
% 均值为0方差为1的高斯白噪声n
n=sqrt(1/2)*(randn(rx,L)+i*randn(rx,L));
% 未叠加噪声的接收信号R
R=zeros(rx,L);
for k=1:L
R(:,k)=sqrt(1/tx)*H(:,:,k)*X(:,k);
end
snr=10^(SNR/10);
R_noised=R+sqrt(1/snr)*n;
x=[];
for t=1:L
r=R_noised(:,t);
HH=H(:,:,t);
G=pinv(HH);
S=[1:tx];
xtemp=zeros(tx,1);
for k=1:tx
[wki,ki]=minnorm(G);
y=wki*r;
if imag(y)<real(y) && imag(y)>-real(y)
xtemp(S(ki))=1;
elseif imag(y)>real(y) && imag(y)>-real(y)
xtemp(S(ki))=i;
elseif imag(y)>real(y) && imag(y)<-real(y)
xtemp(S(ki))=-1;
elseif imag(y)<real(y) && imag(y)<-real(y)
xtemp(S(ki))=-i;
end
r=r-sqrt(1/tx)*xtemp(S(ki))*H(:,S(ki),t);
HH(:,ki)=[];
S(ki)=[];
G=pinv(HH);
end
x=[x,xtemp];
end
% 从x求A的估计a
x1=zeros(tx,L);
for k=1:L
x1(:,k)=pskdemod(x(:,k),4);
end
a=reshape(x1,tx*L,1);
% 比较A和a计算错值率temp_ber
[errbit,temp_ber]=biterr(A,a,2);
berzs=[berzs,temp_ber];
end
semilogy(rx_number,berzs,'s- b');
% MMSE-SIC=================================================================
disp('MMSE-SIC')
bermms=[];
for rx=rx_number
rx
% 快衰落Rayleigh信道H
H=sqrt(1/2)*(randn(rx,tx,L)+i*randn(rx,tx,L));
% 均值为0方差为1的高斯白噪声n
n=sqrt(1/2)*(randn(rx,L)+i*randn(rx,L));
% 未叠加噪声的接收信号R
R=zeros(rx,L);
for k=1:L
R(:,k)=sqrt(1/tx)*H(:,:,k)*X(:,k);
end
snr=10^(SNR/10);
R_noised=R+sqrt(1/snr)*n;
x=[];
for t=1:L
r=R_noised(:,t);
HH=H(:,:,t);
% G=pinv(HH);
G=inv(HH'*HH+(1/snr)*eye(tx))*HH';
S=[1:tx];
xtemp=zeros(tx,1);
for k=1:tx
[wki,ki]=minnorm(G);
% w=inv(HH'*HH+(1/snr)*eye(tx-k+1))*HH';
% y=w(ki,:)*r;
y=wki*r;
if imag(y)<real(y) && imag(y)>-real(y)
xtemp(S(ki))=1;
elseif imag(y)>real(y) && imag(y)>-real(y)
xtemp(S(ki))=i;
elseif imag(y)>real(y) && imag(y)<-real(y)
xtemp(S(ki))=-1;
elseif imag(y)<real(y) && imag(y)<-real(y)
xtemp(S(ki))=-i;
end
r=r-sqrt(1/tx)*xtemp(S(ki))*H(:,S(ki),t);
HH(:,ki)=[];
S(ki)=[];
% G=pinv(HH);
G=inv(HH'*HH+(1/snr)*eye(tx-k))*HH';
end
x=[x,xtemp];
end
% 从x求A的估计a
x1=zeros(tx,L);
for k=1:L
x1(:,k)=pskdemod(x(:,k),4);
end
a=reshape(x1,tx*L,1);
% 比较A和a计算错值率temp_ber
[errbit,temp_ber]=biterr(A,a,2);
bermms=[bermms