How do i assign a random element of an array a new value
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
madhan ravi
le 31 Oct 2018
Modifié(e) : madhan ravi
le 1 Nov 2018
a=maze;
a(randi([1,numel(a)],1,1))='p'
2 commentaires
madhan ravi
le 31 Oct 2018
The above shows an example to select random value and replacing it as another.
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!