How to extract random elements from an array?

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일

0 개 추천

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일

0 개 추천

d ([1 3 6])

카테고리

도움말 센터File Exchange에서 Elementary Math에 대해 자세히 알아보기

태그

질문:

2019년 12월 23일

편집:

2021년 6월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by