Random Selection of Each Element in Vector
Show older comments
Greetings,
I have a vector of 12 elements (a = [10 20 35 38 40 45 48 50 55 58 60 75]') and I want to randomly select one element at a time. How can I do that? Thank you very much.
1 Comment
Accepted Answer
More Answers (1)
a = [10 20 35 38 40 45 48 50 55 58 60 75] ;
N = length(a) ;
pos = 1:N ;
idx = randsample(pos,N) ;
for i = 1:N
a(idx(i))
end
Categories
Find more on Logical 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!