How to pick randomly elements from a vector without repetation?

2 views (last 30 days)
If I have a vector like this :
a=[1 2 3 4 5]
i know how to do this but my vector is something like:
a=[23 46 4 2 5]
I should pick 2 elements randomly without repetation.

Accepted Answer

Bruno Luong
Bruno Luong on 22 Oct 2018
Edited: Bruno Luong on 22 Oct 2018
a(randperm(length(a),2))

More Answers (0)

Categories

Find more on 2-D and 3-D Plots 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!