Select specific number of random ones placed in a zeros matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Chiagoziem Ngwadom
el 17 de Oct. de 2019
Respondida: Guillaume
el 17 de Oct. de 2019
Hi guys, I am trying to make a 1024 by 1024 zeros matrix with specifically 20 ones randomly placed anywhere within the zeros matrix. I feel like it's easy but can anyone help?
0 comentarios
Respuesta aceptada
Guillaume
el 17 de Oct. de 2019
m = zeros(1024, 1024);
m(randperm(numel(m), 20)) = 1; %place 20 ones randomly in m.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices 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!