Randomly changing a value of a matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Phillip Smith
am 21 Nov. 2019
Kommentiert: Phillip Smith
am 21 Nov. 2019
Hello,
I've made a 5x5 matrix of zeros,
I want to randomly change one of the elements to a 1
How would i go about this?
Many thanks
0 Kommentare
Akzeptierte Antwort
the cyclist
am 21 Nov. 2019
Bearbeitet: the cyclist
am 21 Nov. 2019
M = zeros(5,5);
M(randi(25)) = 1;
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!