How to extract random elements from an array?

7 Ansichten (letzte 30 Tage)
Twisha Bansal
Twisha Bansal am 23 Dez. 2019
Bearbeitet: Badavath Swetha am 28 Jun. 2021
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 Kommentar
Stephen23
Stephen23 am 23 Dez. 2019
"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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 23 Dez. 2019
d([1 3 6])
If you want 3 at random then,
d( randperm(length(d),3) )

Weitere Antworten (1)

Badavath Swetha
Badavath Swetha am 28 Jun. 2021
Bearbeitet: Badavath Swetha am 28 Jun. 2021
d ([1 3 6])

Kategorien

Mehr zu Elementary Math finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by