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!