MATLAB: How to pick randomly elements from a vector without repetation

selectingvectors

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.

Best Answer

a(randperm(length(a),2))