📄 petest_dist.m
字号:
%compute the Pe recursively based on pecompute for all possbile Xhat!=X
function [pe2]=petest_dist(snr_db,K,L,Dist0,Dist1,Dist2,m_coef)
%pe2=0; return; % this line for test use only
snr=10^(snr_db/10);
pe2=0;
%X=ones(1,K);
X=rand(1,K)>0.5;
X=X-not(X);
%begin iteration of Xhat
zz=zeros(1,K);
pe2=0;%inital value
for ii=1:2^K-1 %total possible Xhat for BPSKed X
for jj=1:K
if mod(ii,2^(jj-1))==0
zz(jj)=not(zz(jj));
end
end
% till now zz is a vecotor, with 1s and 0s. 1 means that bit is error.
%sum(zz) is the number of error bits
Xhat=X;%initial
for ii=1:K
if zz(ii)==1
Xhat(ii)=-X(ii);% this bit is error
end
end
%src_rly=zeros(1,K);% when this is used, it mean NO contribution of source relays
src_rly=src_gen(K,L);% source relays. Taking into account the contribution of source relay
pe2=pe2+sum(zz)/K*pecompute_dist(K,L,X,Xhat,snr,src_rly,Dist0,Dist1,Dist2,m_coef);
%zz
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -