How do i assign a random element of an array a new value
2 ビュー (過去 30 日間)
古いコメントを表示
I have an array maze=strings(size) where all the elements are "0" How did i randomly choose one of these elements and assign it "P"
0 件のコメント
回答 (2 件)
madhan ravi
2018 年 10 月 31 日
編集済み: madhan ravi
2018 年 11 月 1 日
a=maze;
a(randi([1,numel(a)],1,1))='p'
2 件のコメント
madhan ravi
2018 年 10 月 31 日
The above shows an example to select random value and replacing it as another.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!