random entry selection from a matrix
15 views (last 30 days)
Show older comments
how can I select any element randomly from a 1 x n matrix?
0 Comments
Answers (1)
Doug Hull
on 23 Jul 2012
v = [1:10]
vi = randi(numel(v));
choice = v(vi)
1 Comment
Walter Roberson
on 23 Jul 2012
Doug, you missed your chance to say
choice = v(randperm(numel(v),1));
See Also
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!