📄 vlast_qr_n.m
字号:
function Pb=VLAST_QR_N(SNR_dB)
%------------------------------------------------------------------------
%本程序是对两发两收情况下采用空时分层码的性能分析
%星座映射采用的是BPSK映射
% SNR_dB 接收天线上的接收信噪比,在仿真的过程中把接收信号的功率归一化为1
% Pb是误比特率
%-------------------------------------------------------------------------
SNR=10^(SNR_dB/10);
Cons=sqrt(1/2)*[1 -1]; % BPSK星座
E=1; %接收端的信号功率
No=E/(SNR);%高斯白噪声的功率谱密度
Frame=100000;
ErrorNum=0;
for i=1:1:Frame
x1=Cons((rand(1)>=1/2)+1); % 随机产生发送数据
x2=Cons((rand(1)>=1/2)+1);
X=[x1 x2 ]'; % 进行空时编码
h11=sqrt(1/2)*(randn(1)+j*randn(1)); % 产生信道 两个发送天线到接收天线的信道
h12=sqrt(1/2)*(randn(1)+j*randn(1));
h21=sqrt(1/2)*(randn(1)+j*randn(1));
h22=sqrt(1/2)*(randn(1)+j*randn(1));
H=[h11 h12;h21 h22];
N=sqrt(No/2)*(randn(2,1)+j*randn(2,1)); %接收端的噪声
Y=H*X+N;
[U,R] = qr(H);
y = U'*Y;
decoder_output = zeros(2,1);
decoder_output(2,:) = y(2,:)/(R(2,2)+eps);
for t = 2 : -1 : 1
interf = zeros(1);
for f = (t+1):2
interf = R(t,f)*decoder_output(f,:) + interf;
end
decoder_output(t,:) = (y(t,:) - interf)/(R(t,t)+eps);
end
for k=1:2
if real(decoder_output(k,:))>=0
decoder_output(k,:)=Cons(1);
else decoder_output(k,:)=Cons(2);
end
end
ErrorNum=ErrorNum+(x1~=decoder_output(1,:))+(x2~=decoder_output(2,:));
end
Pb=ErrorNum/(Frame*2);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -