How can I select random element from one of the array in structure?

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)

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

Asked:

on 8 Sep 2015

Answered:

on 8 Sep 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!