📄 petest_main_dist.m
字号:
%Invoke petest to compute theoretical BER vs SNR.
% set K and l values below to evaluate BER
%note that L must be smaller than K
clear all; close all;
begtime=datestr(now)
K=4;
L=3;
SNR = [0 1 2 3 4 5 10 15 20 25 30];
pbkl=zeros(length(SNR),L+1);
pbkl2=zeros(length(SNR),L+1);
m_coef = 3;% distance propogation coefficient
scaling_const = 1.5;% scaling constant to distances, in unit of 100 m
rand('seed',191042387);
numTrial=10
for diii=1:numTrial
diii
Dist0=rand(K,1)*scaling_const/1.5+0.5;%distance of source nodes to base station
Ang0=rand(K,1)*2*pi;%angle of source nodes with respect to base station
Dist2=rand(L,1)*scaling_const/1.5+0.5;%distance of non-source relay to base station
Ang2=rand(L,1)*2*pi;% angle of souce nodes with respect to base station
%%%%%
Dist1=[];
for dtii=1:K
for dtjj=1:L
Dist1(dtii,dtjj) = abs(Dist0(dtii)*exp(j*Ang0(dtii))-Dist2(dtjj)*exp(j*Ang2(dtjj)));% distance of dtii-th source to dtjj-th non-source relay
end
end
for xx=1:length(SNR)
for ll=0:L
pbkl(xx,ll+1)=petest_dist(SNR(xx),K,ll,Dist0,Dist1,Dist2,m_coef);
end
end
pbkl2=pbkl2+pbkl;
end
pbkl2=pbkl2/numTrial;
begtime
endtime=datestr(now)
figure
for xx=1:L+1
hold on;plot(SNR,pbkl2(:,xx))
end
legend('0','1','2','3')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -