1. the rand () function is used to generate values ~ 1) evenly distributed pseudo-random numbers.
Rand (n): Generate N * n 0 ~ 1. a pseudo-random matrix that satisfies the uniform distribution;
Rand (m, n): generates a pseudo-random number of M * n;
Rand (m, n, 'double'): generates double-precision pseudo-random numbers of M * n;
Rand (m, n, 'singles'): generates a single-precision pseudo-random number of M * n;
Note: 'double' and 'singles' single quotes cannot be saved.
2. The randn () function is used to generateStandardA pseudo-random number with a normal distribution.
Usage: 1.
3. The Randi () function is used to generate a pseudo-random integer with a uniform distribution in the range of (Imin ~ IMAX) (open interval). If Imin is set to default, the default value is 1.
Randi (IMAX, 1) or Randi (IMAX): generates 1*1 pseudo random integer smaller than IMAX;
Randi (IMAX, n): generates a pseudo-random matrix N * n Less Than IMAX;
Randi (IMAX, m, n) or Randi (IMAX, [M, N]): generates a pseudo-random matrix of M * n;
Randi (IMAX, M, N, P ,...) or Randi (IMAX, [M, N, P,...]): Generate M * n * p *... pseudo-Random matrix;
Randi (IMAX, size (a): generates a pseudo-random matrix with the same dimension as;
Randi ([Imin, IMAX], n): generates a pseudo-random matrix of N x n with the value range of [Imin, IMAX.
NOTE: If Imin exists, [Imin, IMAX] square brackets cannot be default.
Original article: 79165966
How to Use the rand (), randn (), and Randi () functions of MATLAB