can a random number generator be used in a matrix?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aidan Palermo
am 9 Dez. 2021
Kommentiert: Star Strider
am 9 Dez. 2021
I'm trying to make a minesweeper game in matlab so I set up a matrix A=zeros(10) and I wanted to know if I could write the code so that 1s will be randomly scattered throughout the matrix whenever the code is run.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 9 Dez. 2021
3 Kommentare
Steven Lord
am 9 Dez. 2021
Do you want a certain probability of each cell being a mine or do you want a certain fixed number of mines? In the latter case, use randperm to identify a few locations where the mines are located then fill in those locations with linear indexing.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!