Generate uniform pseudo-random integers from linear range.

バージョン (1.47 KB) 作成者: DS
RAND_INT(R,N) returns an n-by-n matrix containing pseudo-random integer values from range R.

ダウンロード 464 件

更新 2014/1/27


Function that uses RAND to generate random integers in the specified linear range, as follows:

result = floor(a + (b-a+1).* rand(N)),
where specified range is [a b]

Please note: There are lots of ways to do this and lots of interesting submissions on FEX which provide similar results (see below).

random numbers:

#18443 - Random Integer Generator
#5346 - MYRANDINT -- Random Integer Generation
#27942 - WWW.RANDOM.ORG random integers/sequences/strings
#27809 - Unique Random Integer List
#13007 - Random Number Generator
#21353 - True Random Integer Generator (

random arrangement:

#30189 - RANDPERMFULL (derangement)
#17981 - RANDBLOCK
#27076 - Shuffle


DS (2022). Generate uniform pseudo-random integers from linear range. (, MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2007b
Windows macOS Linux
タグ タグの追加

Community Treasure Hunt

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

Start Hunting!