How to select a random number from a matrix

조회 수: 6 (최근 30일)
shalima sudheer
shalima sudheer 2019년 4월 25일
답변: Guillaume 2019년 4월 25일
Hii
I have a matrix A=[2;5;3;6]
How can I select a random number from this matrix A

답변 (1개)

Guillaume
Guillaume 2019년 4월 25일
Use randi to select an index at random:
A(randi(numel(A)))

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by