📄 alam22sg.m
字号:
function ber_22=alam22sg(snr2,Nr,p)
Nt=2;
Nr=Nr;
p=p;
no_bit_sym=1;
bits=10000;
%iter=0;
toterr=0;
% while toterr<soglia
% iter=iter+1;
for i=1:bits
data=(2*round(rand(Nt,1))-1)/(sqrt(2));
%Channel
H=Cor_H(Nr,Nt,p);
%AWGN
sig=sqrt(0.5/(10^(snr2/10)));
n=sig*(randn(Nr,Nt)+j*randn(Nr,Nt));
X=[data(1) -conj(data(2));data(2) conj(data(1))];
R=H*X+n;
%Combiner
s0=0;
s1=0;
for i=1:Nr
s0=conj(H(i,1))*R(i,1)+H(i,2)*conj(R(i,2))+s0;
s1=conj(H(i,2))*R(i,1)-H(i,1)*conj(R(i,2))+s1;
end
%Decoding
if(real(s0)>0)
Decoded1=1;
else
Decoded1=-1;
end
if(real(s1)>0)
Decoded2=1;
else
Decoded2=-1;
end
decoded=[Decoded1 Decoded2];
% dh=sqrt(2)*[1 -1]/2;
% d11=((dh(1)-real(S(1)))^2+(imag(S(1)))^2);
% d12=((dh(2)-real(S(1)))^2+(imag(S(1)))^2);
% D1=[d11 d12];
%
% d21=((dh(1)-real(S(2)))^2+(imag(S(2)))^2);
% d22=((dh(2)-real(S(2)))^2+(imag(S(2)))^2);
% D2=[d21 d22];
% %Decision
% [scelta1,posizione1]=min(D1);
% [scelta2,posizione2]=min(D2);
% decoded=[dh(posizione1) dh(posizione2)];
err_m1=sum(round(data')~=round(decoded));
toterr=err_m1+toterr;
end
%end
ber_22=toterr/(bits*2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -