How can I generate a matrix of pseudo-random floating point values from a uniform distribution(5, 8), but without range() function and other ToolBoxes?

4 ビュー (過去 30 日間)
How can I generate a matrix of pseudo-random floating point values from a uniform distribution(5, 8), but without range() function and other ToolBoxes?
matrix = rrange(1) + range( rrange ) * rand( 5, 8 ) % now I have this variant,
% it works, but I cannot use ToolBoxes

採用された回答

Jan
Jan 2022 年 12 月 4 日
移動済み: Jan 2022 年 12 月 5 日
Does this mean, that you cannot use rand()?
range() is trivial to replace: rrange(2)-rrange(1)
  2 件のコメント
Ihor
Ihor 2022 年 12 月 4 日
移動済み: Jan 2022 年 12 月 5 日
Oh, thank you. Frankly, I meant range(), bud I did not know what does it do)
Steven Lord
Steven Lord 2022 年 12 月 5 日
In general, if you're not sure what a function does or which MathWorks product includes it, take a look at the documentation for that function. In particular, if you look at the rand function's documentation the "Random Numbers Within Specified Interval" example exactly matches what you're trying to do.
If you're using the range function from Statistics and Machine Learning Toolbox, for a general vector calling the bounds function in MATLAB with two output arguments and subtracting the first output from the second does the same thing as range. For a 2-element vector in increasing order this simplifies to the replacement @Jan posted.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by