Randomly generate a vector containing integers. Extract items from odd positions using a single command line
Mostrar comentarios más antiguos
Hi guys. How can i randomly generate a vector containing integers and extract items from odd positions using a single command line?
Thank you!
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 3 de Mzo. de 2022
struct('d',randi(100,1,1)).d(1:2:end)
Does not require that the number of values is even.
Seems pointless to me unless you are carefully controlling the random seed. Just wastes time and is unclear. The numbers are not more random by taking every second one instead of all of them.
1 comentario
Dacian Andrei Firca
el 16 de Mzo. de 2022
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!