Table Of Contents

randint

Version:
    Last Modified: January 9, 2017

    Generates uniformly distributed pseudorandom integers in the range you specify. randint uses the same pseudorandom number generator as rand.

    Syntax

    e = randint(a)
    e = randint(a, b)
    e = randint(a, b, range)
    e = randint(a, b, c)
    e = randint(a, b, range, s)
    e = randint(a, b, c, s)

    Inputs

    a

    Number of rows in e. a is a positive integer.

    b

    Number of columns in e. b is a positive integer.

    range

    Range of pseudorandom integers to generate. range is an integer. If range is positive, MathScript generates pseudorandom integers in the interval [0, range-1]. If range is 0, MathScript generates integers of 0. If range is negative, MathScript generates pseudorandom integers in the interval [range+1, 0]. The default range is 2, and MathScript generates pseudorandom integers in the interval [0, 1].

    c

    Lower and upper bound of the interval of pseudo-random integers to generate, which are separated by a comma or white spaces and enclosed in square brackets. c is an array with two integer values.

    s

    Seed of the pseudorandom number generator used for the next call of the function.

    Outputs

    e

    a-by-b matrix of uniformly distributed pseudorandom integers in the interval you specify. If you do not specify b, e returns a square matrix of length a.

    A = randint(1)
    B = randint(3, 4)
    C = randint(1, 10, 8)
    D = randint(10, 2, [-4 4])
    E = randint(5, 1, 0, 99)
    F = randint(3, 4, [-1, 1], 99)

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: Not supported


    Recently Viewed Topics