how can I generate random decimal numbers in a specific decimal range?

29 ビュー (過去 30 日間)
sanam
sanam 2019 年 6 月 13 日
コメント済み: sanam 2019 年 6 月 13 日
hello everyone
I want to generate random decimal numbers in this range:
tt1=randi([-2.96706,2.96706],1,6);
tt2=randi([-1.5708,2.61799],1,6);
tt3=randi([-1.74533,1.36626],1,6);
tt4=randi([-2.70526,2.70526],1,6);
tt5=randi([-2.35619,2.35619],1,6);
tt6=randi([-3.49066,3.49066],1,6);
matlab shows errors. how can I make it?
thank you in advance
  2 件のコメント
Stephen23
Stephen23 2019 年 6 月 13 日
Note that the randi documentation uses the word "integer" forty-two times, and clearly explains that it only returns integers for all of its syntaxes.
Why are you trying to use it to generate non-integers?
sanam
sanam 2019 年 6 月 13 日
yes I got it, I think I can use linspace instead of that

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

採用された回答

Stephen23
Stephen23 2019 年 6 月 13 日
v = [-2.96706,2.96706];
v(1)+diff(v)*rand(1,6)

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by