How do i assign a random element of an array a new value
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
madhan ravi
il 31 Ott 2018
Modificato: madhan ravi
il 1 Nov 2018
a=maze;
a(randi([1,numel(a)],1,1))='p'
2 Commenti
madhan ravi
il 31 Ott 2018
The above shows an example to select random value and replacing it as another.
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!