creating binary vector with determed number of ones
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
loukil sana
el 24 de Abr. de 2019
Comentada: loukil sana
el 24 de Abr. de 2019
Hello,
i have a vector V= 50; i want to full this vector randomly with 0 and 1. the '1' appears 10 times and the rest of the vector with zeros. how can i do that please
0 comentarios
Respuesta aceptada
John D'Errico
el 24 de Abr. de 2019
Editada: John D'Errico
el 24 de Abr. de 2019
nones = 10;
nv = 50;
V = zeros(1,nv);
V(randperm(nv,nones)) = 1;
3 comentarios
John D'Errico
el 24 de Abr. de 2019
I'm sorry. I cannot/will not keep on chasing totally new questions in the comments. That turns one question into an extended personal consulting session. If you have another question, then ask it. AS ANOTHER QUESTION.
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!