I am trying to randomly disperse different numbers in MATLAB array:
古いコメントを表示
I am trying to randomly disperse different numbers in MATLAB array:
I have two 3's, four 2's and I want to randomly populate ones vector (size 10,1).
End Result look something like this:
A = [1; 3; 1; 2; 3; 2; 2; 1; 1; 2; 1; 1]
Then I want to fix the values in A but add more random elements but I can only replace with higher numbers:
for example, to the matrix above I will randomly add two more 2's and two more 3's giving something like this
A2 =[ 3; 3; 2; 2; 3; 2; 2; 2; 1; 2; 1; 3]
2 件のコメント
Jos (10584)
2014 年 2 月 25 日
編集済み: Jos (10584)
2014 年 2 月 25 日
Two questions:
- Is it also allowed to replace 2's but 3's, or can only 1's change into higher number?
- Do you specify how many new 2's or 3's have to appear, or do you only set the total number of changes?
Keith
2014 年 2 月 25 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!