How can I randomly extract a element in a vector?

3 次查看(过去 30 天)
Hi!!
How can I extract a random element from a vector?
For example, I have vector v = [a1 a2 a3 a4] and I want to randomly select one of the elements. ~
Thanks!!

采纳的回答

Torsten
Torsten 2020-4-6
编辑:Torsten 2020-4-6
random_element = v(randi(numel(v)))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by