Getting a random list of numbers on a very specific interval

3 ビュー (過去 30 日間)
Evan Bakalars
Evan Bakalars 2021 年 2 月 25 日
編集済み: James Tursa 2021 年 2 月 25 日
How would I go about getting a list of 10000 random numbers (using rng('shuffle')), between 0 and 90, but does not include any numbers between 40 and 50. I dont want to split it by saying give 5000 random numbers from 0-40 and 5000 for 50-90.

採用された回答

James Tursa
James Tursa 2021 年 2 月 25 日
編集済み: James Tursa 2021 年 2 月 25 日
Generate the list according to the range width of valid values, then adjust the results. E.g.,
r = rand(10000,1)*80;
ix = r > 40;
r(ix) = r(ix) + 10;

その他の回答 (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