How to select element from vector

20 ビュー (過去 30 日間)
Marat Zhe
Marat Zhe 2018 年 6 月 14 日
コメント済み: Marat Zhe 2018 年 6 月 14 日
__Hi guys. I've got a vector (for exhample) A=[5,4,7,9,11,2,16] (generally vector may be bigger).
1. I want to take random element a1 from it (now vector A have size 1*7).
2. Then i want to take one more random element a2 from A with out of a1 !!
etc.
__So i want to take all elements from vector A.
__Can you give me a clue, how to do it in a simplest way.
__Thanks in advance!!

採用された回答

KSSV
KSSV 2018 年 6 月 14 日
A=[5,4,7,9,11,2,16] ;
idx = randperm(length(A)) ;
iwant = A(idx)
  3 件のコメント
KSSV
KSSV 2018 年 6 月 14 日
iwant is randomly arranged from A. Run a loop on iwant and pick.
Marat Zhe
Marat Zhe 2018 年 6 月 14 日
Thank you very much KSSV. I've finally got what you meant.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by