What is the difference between rand and randi when using it in a 3D array

 采纳的回答

Its similar as usual, rand for uniformly distributed random number including floatings numbers, whereas randi for integers.

更多回答(1 个)

Maybe try this:
array(randi([1 length(array)],1))

8 个评论

Doesn’t it work? You changed the question?
When dealing with 3D arrays if im looking to extract one random point what is the reason behind using randi?
randi produces random integer numbers and rand produces random floating numbers
randi was used here because the index of an array should be an integer.
Give a vote for my answer if you find it useful :)

请先登录,再进行评论。

类别

帮助中心File 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