How to extract random elements from an array?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Twisha Bansal
el 23 de Dic. de 2019
Editada: Badavath Swetha
el 28 de Jun. de 2021
For eg., I have a 1d array, d=[1;3;4;6;8;7;8;9;6;7] and I need to extract the first, third and sixth variable. How do I do that?
1 comentario
Stephen23
el 23 de Dic. de 2019
"I need to extract the first, third and sixth variable."
There is only one variable, the vector d.
The vector d has elements, and most likely you are trying to extract those elements.
Respuesta aceptada
Walter Roberson
el 23 de Dic. de 2019
d([1 3 6])
If you want 3 at random then,
d( randperm(length(d),3) )
0 comentarios
Más respuestas (1)
Badavath Swetha
el 28 de Jun. de 2021
Editada: Badavath Swetha
el 28 de Jun. de 2021
d ([1 3 6])
0 comentarios
Ver también
Categorías
Más información sobre Elementary Math 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!