matlab 中抽取随机数的函数
来源:百度知道 编辑:UC知道 时间:2024/05/14 12:39:57
设取值区间为[a,b],则要在此区间选取一个随机数,程序为:
a=rand()*(b-a)+a
若要求随机数是整数,则程序为:
a=ceil(rand()*(b-a))+a
这样即可!!!
help rand
RAND Uniformly distributed random numbers.
RAND(N) is an N-by-N matrix with random entries, chosen from
a uniform distribution on the interval (0.0,1.0).
RAND(M,N) and RAND([M,N]) are M-by-N matrices with random entries.
RAND(M,N,P,...) or RAND([M,N,P,...]) generate random arrays.
RAND with no arguments is a scalar whose value changes each time it
is referenced. RAND(SIZE(A)) is the same size as A.
RAND produces pseudo-random numbers. The sequence of numbers
generated is determined by the state of the generator. Since MATLAB
resets the state at start-up, the sequence of numbers generated will
be the same unless the state is changed.
S = RAND('state') is a 35-element vector containing the curre