How do I generate an n x n array using a random-number generator?

Like the question says, is there a function that can easily do this or how would I write the code to do this?

回答 (1 件)

Image Analyst
Image Analyst 2013 年 11 月 13 日

0 投票

randomArray = rand(n);

3 件のコメント

Todd Jones
Todd Jones 2020 年 4 月 13 日
rand only displays random values less than 1. What about an infinite range of random numbers?
Image Analyst
Image Analyst 2020 年 4 月 13 日
Try
randomArray = realmax('double') * rand(n);
1.79769313486232e+308 is as high as you can go and there is no reason to go higher for any real world situation as far as I know.
Steven Lord
Steven Lord 2020 年 4 月 13 日
Todd Jones: from which distribution do you want your "infinite range" of random numbers to be drawn? Remember that the integral of the PDF of the distribution over the real line needs to be 1. which limits somewhat the distributions from which you can draw.

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

カテゴリ

ヘルプ センター および File ExchangeRandom Number Generation についてさらに検索

質問済み:

2013 年 11 月 13 日

コメント済み:

2020 年 4 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by