MX_RAND – Randomly generated matrix or vector

Block SymbolLicensing group: STANDARD
PIC

Function Description
The function block MX_RAND generates random elements of the matrix or vector referenced by uMV.

The output reference yMV is always set to the corresponding input references uMV. If HLD = on then nothing is generated otherwise pseudo-random values of the matrix or vector elements referenced by uMV are generated using these rules:

  • If the parameter BIP is on then the generated elements are inside the interval [scale;scale] else they are inside the interval [0;scale].
  • Elements are internally generated using the standard C language function rand() which generates pseudo-random numbers in the range from 0 to RAND_MAX. Note, that the value of RAND_MAX can be platform dependent (and it should be at least 32767).
  • The rising edge on the input SET causes that the standard C language function srand(nseed) (initailizes the pseudo-random generator with the value of nseed) is called before the generation of random elements. The same sequences of pseudo-random numbers are generated after calls of srand(nseed) for the same values of nseed.

The error flag E is set to on if the reference uMV is not defined (i.e. input uMV is not connected).

Inputs

uMV

Input reference to a matrix or vector

Reference

nseed

Random number seed  0.00E+00

Long(I32)

SET

Set initial value of random number generator to nseed on rising edge

Bool

HLD

Hold

Bool

Parameters

BIP

Bipolar random values flag

Bool

scale

Random values multiplication factor  1.0

Double (F64)

Outputs

yMV

Output reference to a matrix or vector

Reference

E

Error indicator

Bool

2020 © REX Controls s.r.o., www.rexygen.com