How can I select random element from one of the array in structure?
Mostrar comentarios más antiguos
I have a structure named peer which has 2 arrays value[] and age[]. I want to select random element from value[]and assign it to variable p. Could you please guide me about it? Thanks
Respuestas (1)
Walter Roberson
el 8 de Sept. de 2015
p = peer.value(randi(numel(peer.value)))
If you have the statistics toolbox then you can use randsample I think the routine name is
Categorías
Más información sobre Random Number Generation 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!