What is the difference between rand and randi when using it in a 3D array
Show older comments
What is the difference between rand and randi when using it in a 3D array
Accepted Answer
More Answers (1)
madhan ravi
on 25 Aug 2018
Maybe try this:
array(randi([1 length(array)],1))
8 Comments
madhan ravi
on 25 Aug 2018
Edited: madhan ravi
on 25 Aug 2018
Doesn’t it work? You changed the question?
Shivam
on 25 Aug 2018
madhan ravi
on 25 Aug 2018
randi produces random integer numbers and rand produces random floating numbers
madhan ravi
on 25 Aug 2018
randi was used here because the index of an array should be an integer.
madhan ravi
on 25 Aug 2018
Was my answer different?
Shivam
on 25 Aug 2018
madhan ravi
on 25 Aug 2018
Give a vote for my answer if you find it useful :)
Foad Brakhasi
on 18 Jan 2023
Thanks it was useful.
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!