1、产生连续均匀分布的随机数组——unifrnd
语法格式:
R = unifrnd(A,B)
R = unifrnd(A,B,m,n,…)
R = unifrnd(A,B,[m,n,…])
描述:
R = unifrnd(A,B) returns an array R of random numbers generated from the continuous uniform distributions with lower and upper endpoints specified by A and B, respectively. If A and B are arrays, R(i,j) is generated from the distribution specified by the corresponding elements of A and B. If either A or B is a scalar, it is expanded to the size of the other input.
解析:生成被A和B指定上下端点[A,B]的连续均匀分布的随机数组R。 如果A和B是数组,R(i,j)是生成的被A和B对应元素指定连续均匀分布的随数。 如果N或P是标量,则被扩展为和另一个输入有相同维数的数组。
R = unifrnd(A,B,m,n,…) or R = unifrnd(A,B,[m,n,…]) returns an m-by-n-by-… array. If A and B are scalars, all elements of R are generated from the same distribution. If either A or B is an array, they must be m-by-n-by-… .
解析:如果A和B是标量,R中所有元素是相同分布产生的随机数。 如果A或B是数组,则必须是m*n…数组。
A和B可以是向量也可以是标量。
(1)若两个都是向量,则两者都是列向量或都是行向量,而且维数相等,从A到B产生一系列区间,并且区间个数等于他们的维数。
x = [1:9];
y