필터 지우기
필터 지우기

Generate random numbers from a vector

조회 수: 1 (최근 30일)
Angus Wong
Angus Wong 2019년 10월 3일
댓글: Angus Wong 2019년 10월 3일
I would like Matlab to give me a number from a given row vector, such as:
A=[1 3 5 9 100 150 658 999];
Matlab would either give me 1,3,5,9,100,150,658, or 999 in a random manner.(Only one output.)
How can I do this? Many thanks.

채택된 답변

the cyclist
the cyclist 2019년 10월 3일
Here's one way:
A(randi(numel(A)))
  댓글 수: 1
Angus Wong
Angus Wong 2019년 10월 3일
Thank you for the quick response!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by