values of matrix change on each iteration
1 回表示 (過去 30 日間)
古いコメントを表示
if we want a matrix
A=[7x3] such that we iterate 100 times and its values chnage from 1 to 3 randomly on each iteration e.g
A=[1 1 1
2 1 3
1 2 1
3 3 2
3 1 2
1 1 1
2 1 3]
and in next iteration it changes again
0 件のコメント
採用された回答
Stephen23
2016 年 12 月 15 日
編集済み: Stephen23
2016 年 12 月 15 日
for k = 1:100
A = randi([1,3],7,3)
end
2 件のコメント
Stephen23
2016 年 12 月 16 日
編集済み: Stephen23
2016 年 12 月 16 日
"how this works": it generates a new random matrix in a loop, giving exactly what you requested.
"where is k in it to iterate?" I do not understand the question. The loop variable k is not used because it is not required to generate a new random matrix.
その他の回答 (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!