⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ostbc_ber.m

📁 simulation of BER of orthogonal space time block code over frequency flat Rayleigh faing channel
💻 M
字号:
% This program simulates the bit-error-rate (BER) performance of OSTBC
% with L=4 antennas over the frequency flat Rayleigh block fading channel 
% The code is developed for real orthogonal design, code rate 1/2;
% modulation- 16 QAM with gray coding resulting in 2 bits/sec/Hz.

% by Samat Shabdanov, February 2007, e-mail:shabdanov@yahoo.com




%16 QAM constellation
x=[-3 -3 -3 -3   -1 -1 -1 -1  3 3 3  3    1 1 1  1  ];
y=[3  1  -3 -1    3  1 -3 -1  3 1 -3 -1   3 1 -3 -1 ];

Qam=x+y*i;
Es=10; %average constellation energy for d=2;

index=1;

%set SNR step
step=4;

% SNR range is here
for SNR=4:step:20
    
%number of bit errors set to zero
count=0;


%number of iterations
N=10^4;
if SNR==20 N=3*10^4; end; % increase for higher SNR
 
    
for it=1:N
    
%generate 16 bits uniformly distributed 
A=round(rand(1,16));

% TX symbols
s1=Qam(bi2de(A(1:4),'left-msb')+1);
s2=Qam(bi2de(A(5:8),'left-msb')+1);
s3=Qam(bi2de(A(9:12),'left-msb')+1);
s4=Qam(bi2de(A(13:16),'left-msb')+1);


C1=[s1 s2 s3 s4; -s2 s1 -s4 s3; -s3 s4 s1 -s2; -s4 -s3 s2 s1]; 
C=[C1; conj(C1)];


%Channel coefficients
Z=0;
K=1/sqrt(2)*(randn(4,1)+i*randn(4,1)); % normalize to the variance 1 CN(0,1)

%AWGN channel 
N0=(4*Es/10^(SNR/10));
Z=sqrt(N0/2)*(randn(8,1)+i*randn(8,1)); % variance N0

%RX symbols

R=C*K+Z; 


%decoding ML OSTBC

H1=[K(1) K(2) K(3) K(4); K(2) -K(1) -K(4) K(3); K(3) K(4) -K(1) -K(2); K(4) -K(3) K(2) -K(1)];

H=[H1 conj(H1)];


R=[R(1:4); conj(R(5:8))];

%symbol-wise decoding
S=R.'*H'/(2*sum(abs(K).^2));

%symbol decoding for 16-QAM

L=[ abs(Qam-S(1)); abs(Qam-S(2)); abs(Qam-S(3)); abs(Qam-S(4))];

[D,I]=min(L,[],2);


%TX bits
dec_bits(1,1:4)=de2bi(I(1)-1,4,'left-msb');
dec_bits(1,5:8)=de2bi(I(2)-1,4,'left-msb');
dec_bits(1,9:12)=de2bi(I(3)-1,4,'left-msb');
dec_bits(1,13:16)=de2bi(I(4)-1,4,'left-msb');

%count errors
count=count+sum(abs(A-dec_bits));

end;

B_err(index)=count/(N*16)
index=index+1;

end;

semilogy(4:step:20, B_err);




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -