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

madhan ravi
madhan ravi 2018 年 8 月 25 日
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?
Shivam
Shivam 2018 年 8 月 25 日
When dealing with 3D arrays if im looking to extract one random point what is the reason behind using randi?
madhan ravi
madhan ravi 2018 年 8 月 25 日
randi produces random integer numbers and rand produces random floating numbers
madhan ravi
madhan ravi 2018 年 8 月 25 日
randi was used here because the index of an array should be an integer.
madhan ravi
madhan ravi 2018 年 8 月 25 日
Was my answer different?
Shivam
Shivam 2018 年 8 月 25 日
Thank you bhai :)
madhan ravi
madhan ravi 2018 年 8 月 25 日
Give a vote for my answer if you find it useful :)
Foad Brakhasi
Foad Brakhasi 2023 年 1 月 18 日
Thanks it was useful.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by