📄 rayleigh1.asv
字号:
function b=rayleigh1
clear all;
clf;
a=10; % uniform distribution between 0 and a
N=4;
trange=1;
T=unifrnd(0,a,2,N);% there are totally N transmission nodes in the network
plot(T(1,:),T(2,:),'r*','MarkerSize',10);
axi
R=ones(2,N);
c=ones(2,N);
incide=zeros(1,N);
i=1;
while i<N+1
c1=unifrnd(0,a,2,1);
c(1,:)=c1(1,1);
c(2,:)=c1(2,1);
incidefind=find(incide);
for j=1:1:length(incidefind)
c(1,incide(1,j))=100;
c(2,incide(1,j))=100;
end
abst=((T(1,:)-c(1,:)).^2+(T(2,:)-c(2,:)).^2).^0.5;
[minvalue,incide1]=min(abst);
if minvalue<trange
R(1,i)=c1(1,1);
R(2,i)=c1(2,1);
incide(1,i)=incide1;
i=i+1;
end %the receiving node is in the transmission range
end %there are totally N receiving nodes
hold on;
plot(R(1,:),R(2,:),'b*','MarkerSize',10);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -