Generating random decimals with a range

10 ビュー (過去 30 日間)
chantel
chantel 2023 年 10 月 1 日
コメント済み: chantel 2023 年 10 月 3 日
I need to create a table using random numbers, i am having an issue with getting correct digits within a specified range. The range is 500.57 to 2000.75 and the random numbers must be 2 decimals

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 10 月 1 日
%Change the display format
format longg
%Generate random number between [min max]*10^(num_of_demicals)
%and divide the output by 10^(num_of_demicals)
y = randi([50057 200075],10,1)/100;
disp(y)
661.21 1313.32 1785.45 1963.6 1042.08 592.53 1087.34 1383.99 699.65 723.99
  1 件のコメント
chantel
chantel 2023 年 10 月 3 日
Thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by