How to select a random number from a matrix

4 次查看(过去 30 天)
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