How can I select random element from one of the array in structure?
Show older comments
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
Answers (1)
Walter Roberson
on 8 Sep 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
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!