How to select a random number from a matrix

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일

4 개 추천

Use randi to select an index at random:
A(randi(numel(A)))

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2019년 4월 25일

답변:

2019년 4월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by