The fastest way to create a random network?

1 回表示 (過去 30 日間)
Ulrik William Nash
Ulrik William Nash 2018 年 1 月 8 日
回答済み: Roger Stafford 2018 年 1 月 8 日
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

採用された回答

Roger Stafford
Roger Stafford 2018 年 1 月 8 日
A = 1*(beta>=rand(n));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by