How to pick randomly elements from a vector without repetation?

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.

 採用された回答

Bruno Luong
Bruno Luong 2018 年 10 月 22 日
編集済み: Bruno Luong 2018 年 10 月 22 日

1 投票

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

その他の回答 (0 件)

質問済み:

2018 年 10 月 22 日

編集済み:

2018 年 10 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by