how to choose some rows from a matrix randomly in turns? I mean increasingly counter

1 回表示 (過去 30 日間)
ramin asadi
ramin asadi 2016 年 11 月 12 日
コメント済み: Star Strider 2016 年 11 月 12 日
how to choose some rows from a matrix randomly in turns? I mean increasingly counter. for example if data is [1,2,3,4,5,6,7,8,9] the random choosing needs to be [1,4,5,7,9], but not [5,1,7,2,4]

回答 (1 件)

Star Strider
Star Strider 2016 年 11 月 12 日
I am not certain what your criteria are.
See if this does what you want:
v = [1,2,3,4,5,6,7,8,9];
idx = randperm(length(v), 5); % Choose 5 Elements Randomly
random_choosing = sort(v(idx)) % Random Elements (Sorted In Ascending Order)
random_choosing =
2 4 6 7 8
  2 件のコメント
ramin asadi
ramin asadi 2016 年 11 月 12 日
thanks a lot. it worked.
Star Strider
Star Strider 2016 年 11 月 12 日
My pleasure.
Since my Answer solved your problem, please Accept it!

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

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by