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

 Accepted Answer

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

More Answers (1)

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

8 Comments

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 :)

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!