Select a random element of a vector and use randi command
Mostrar comentarios más antiguos
What command should I use to randomly select an element from a vector and give it a random number by using the randi command while also displaying the other elements in the workspace?
Respuestas (1)
KSSV
el 1 de Mzo. de 2021
A = magic(5) ;
A = A(:) ;
N = numel(A) ;
idx = randi(N,1) ;
A(idx) = rand
1 comentario
Eric Junaeus
el 2 de Mzo. de 2021
Editada: Eric Junaeus
el 2 de Mzo. de 2021
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!