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

 채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 8월 25일
편집: KALYAN ACHARJYA 2018년 8월 25일

6 개 추천

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

madhan ravi
madhan ravi 2018년 8월 25일
편집: madhan ravi 2018년 8월 25일
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.
Was my answer different?
Thank you bhai :)
Give a vote for my answer if you find it useful :)
Thanks it was useful.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2018년 8월 25일

댓글:

2023년 1월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by