Create a matrix using rand function with a value range
18 ビュー (過去 30 日間)
古いコメントを表示
Hi all, how can I create a 50x50 matrix using Random (rand) function while the condition is all the values of the matrix will be in between 0 to 0.004?
0 件のコメント
採用された回答
Stephen23
2021 年 10 月 28 日
0.004*rand(50,50)
2 件のコメント
Steven Lord
2021 年 10 月 28 日
That's almost correct. That's the syntax suggested in the "Random Numbers Within Specified Interval" example on the documentation page for the rand function but you're using a and b inconsistently.
You want to generate numbers with the lower limit a being 0 and the upper limit b being 0.004.
a = 0;
b = 0.004;
N = 10;
r = a + (b-a).*rand(N,1)
checkInterval = all((a < r) & (r < b))
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!