How to extract random elements from an array?

9 ビュー (過去 30 日間)
Twisha Bansal
Twisha Bansal 2019 年 12 月 23 日
編集済み: Badavath Swetha 2021 年 6 月 28 日
For eg., I have a 1d array, d=[1;3;4;6;8;7;8;9;6;7] and I need to extract the first, third and sixth variable. How do I do that?
  1 件のコメント
Stephen23
Stephen23 2019 年 12 月 23 日
"I need to extract the first, third and sixth variable."
There is only one variable, the vector d.
The vector d has elements, and most likely you are trying to extract those elements.

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 12 月 23 日
d([1 3 6])
If you want 3 at random then,
d( randperm(length(d),3) )

その他の回答 (1 件)

Badavath Swetha
Badavath Swetha 2021 年 6 月 28 日
編集済み: Badavath Swetha 2021 年 6 月 28 日
d ([1 3 6])

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by