Randomly changing a value of a matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Phillip Smith
el 21 de Nov. de 2019
Comentada: Phillip Smith
el 21 de Nov. de 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 comentarios
Respuesta aceptada
the cyclist
el 21 de Nov. de 2019
Editada: the cyclist
el 21 de Nov. de 2019
M = zeros(5,5);
M(randi(25)) = 1;
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!