📄 stbc_2t1r_bpsk_uncorr_rayleigh.m
字号:
%SNR in dB;
function [BER,Raw_BER]=stbc_2t1r_bpsk_uncorr_Rayleigh(SNR,SimBits)
%Generate source;
T1_InforSource=randint(1,SimBits/2,[0,1]);
T2_InforSource=randint(1,SimBits/2,[0,1]);
%BPSK modulation;
T1_InforSymbol=(T1_InforSource-0.5)*2;
T2_InforSymbol=(T2_InforSource-0.5)*2;
%STBC Tx2Rx2 encoding;
scale=sqrt(2);%total power of all transmitters are normalized to 1;
T1_STBC_Symbol=[T1_InforSymbol;-T2_InforSymbol]/scale;
T1_STBC_Symbol=reshape(T1_STBC_Symbol,1,SimBits);
T2_STBC_Symbol=[T2_InforSymbol;T1_InforSymbol]/scale;
T2_STBC_Symbol=reshape(T2_STBC_Symbol,1,SimBits);
%Independent Rayleigh fading channel; h is constant between adacent
%symbols;
h1=sqrt(0.5)*(randn(1,SimBits/2)+j*randn(1,SimBits/2));
h1=[h1;h1];
h1=reshape(h1,1,SimBits);
h2=sqrt(0.5)*(randn(1,SimBits/2)+j*randn(1,SimBits/2));
h2=[h2;h2];
h2=reshape(h2,1,SimBits);
h=[h1;h2];
Raw_h=sqrt(0.5)*(randn(1,SimBits)+j*randn(1,SimBits));
noise=sqrt(10^(-SNR/10.0)/2)*(randn(1,SimBits)+j*randn(1,SimBits));
Raw_noise=sqrt(10^(-SNR/10.0)/2)*(randn(1,SimBits)+j*randn(1,SimBits));
%Received signals with STBC;
Received_Symbol=sum([T1_STBC_Symbol;T2_STBC_Symbol].*h,1)+noise;%Note: noise power is just added at the receiver;
%Received signals without STBC;
Raw_Received_Symbol=[T1_InforSymbol T2_InforSymbol].*abs(Raw_h)+Raw_noise;
%STBC decoding;
h1_temp=reshape(h(1,:),2,SimBits/2);
h2_temp=reshape(h(2,:),2,SimBits/2);
h_temp=[h1_temp(1,:);h2_temp(1,:)];
h_temp=reshape(h_temp,1,SimBits);
[Combined_Signal_real,Combined_Signal_imag]=STBC_2t1r_Dec(real(h_temp),imag(h_temp),real(Received_Symbol),imag(Received_Symbol));
Combined_Signal=Combined_Signal_real+j*Combined_Signal_imag;
%for k=1:2:SimBits
% Combined_Signal_temp(k)=conj(h(1,k))*Received_Symbol(1,k)+h(2,k)*conj(Received_Symbol(1,k+1));
% Combined_Signal_temp(k+1)=conj(h(2,k))*Received_Symbol(1,k)-h(1,k)*conj(Received_Symbol(1,k+1));
%end
Combined_Signal=reshape(Combined_Signal,2,SimBits/2);
%BPSK demodulation;
T1_Sink=(sign(real(Combined_Signal(1,:)))+1)/2;
T2_Sink=(sign(real(Combined_Signal(2,:)))+1)/2;
Raw_T1_Sink=(sign(real(Raw_Received_Symbol(1:SimBits/2)))+1)/2;
Raw_T2_Sink=(sign(real(Raw_Received_Symbol(SimBits/2+1:SimBits)))+1)/2;
%Error statistics;
BER=(length(find(T1_InforSource - T1_Sink))+length(find(T2_InforSource - T2_Sink)))/(SimBits);
Raw_BER=(length(find(T1_InforSource - Raw_T1_Sink))+length(find(T2_InforSource - Raw_T2_Sink)))/(SimBits);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -