How do i get decimal values using randi?
4 ビュー (過去 30 日間)
古いコメントを表示
.png)
Im supposed to create a 3x4 matrix with random decimal value from -10 to 20. Im not sure how to get decimal values.
0 件のコメント
採用された回答
Adam Danz
2020 年 2 月 5 日
編集済み: Adam Danz
2020 年 2 月 5 日
randi() will only return integers. Instead, use rand() which will prouduce random values between 0 and 1; then scale and shift the results to the defined bounds.
arraySize = [3,4];
bounds = [-10,20];
x = rand(arraySize)*range(bounds)+bounds(1);
0 件のコメント
その他の回答 (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!