1. rand 函数。
rand Uniformly distributed pseudorandom numbers.
R = rand(N) returns an N-by-N matrix containing pseudorandom values drawn
from the standard uniform distribution on the open interval(0,1). rand(M,N)
or rand([M,N]) returns an M-by-N matrix. rand(M,N,P,...) or
rand([M,N,P,...]) returns an M-by-N-by-P-by-... array. rand returns a
scalar. rand(SIZE(A)) returns an array the same size as A.
Note: The size inputs M, N, P, ... should be nonnegative integers.
Negative integers are treated as 0.
R = rand(..., 'double') or R = rand(..., 'single') returns an array of
uniform values of the specified class.
The sequence of numbers produced by rand is determined by the settings of
the uniform random number generator that underlies rand, RANDI, and RANDN.
Control that shared random number generator using RNG.
Examples:
Example 1: Generate values from the uniform distribution on the
interval [a, b].
r = a + (b-a).*rand(100,1);
Example 2: Use the RANDI function, instead of rand, to generate
integer values from the uniform distribution on the se