Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
在下面的Matlab代码中,节点为N=10 ,您将获得随机选择的节点,概率为P= .25标记为红色节点。
nodeN = []; nodeM = []; N=input('No. of Nodes:'); P=input('probability of cluster head : '); R=input('range of cluster head: ') data = rand(N,2) % Randomly generated n no. of nodes x = data(:,1); y = data(:,2); plot(x,y,'b*') hold on index = (rand(N,1) |
![]() |
![]() |