The fastest way to create a random network?
2 次查看(过去 30 天)
显示 更早的评论
I am trying to create a square matrix of 1's and zeros, where 1's represents a communication link and 0's represents a lack of the same. In this matrix, the probability of observing 1 at each location is given by beta.
What is the most efficient way to create the stated network? I have tried the following, but there are no doubt better ways:
n = 100 beta = 0.25
A = rand(n,n) B = find(A<=beta) C = find(A>beta) A(B) = 1 A(C) = 0
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!