Mitsubishi QD51 Programming Manual page 535

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
RND
Function
• Generates random numbers.
RND(<numeric expression>)
Syntax
numeric expression
A=RND(1)
Examples
B=RND(0)
C=RND(-1)
• The RND function generates a random number in the interval from 0 and up to, but not
Description
including, 1.
• The generated random number varies depending on the value specified in <numeric
expression>.
If <numeric expression> is positive
If <numeric expression> is 0
If <numeric expression> is negative
Program Example
10 ' This program generates random numbers
20 DIM A(10)
30 PRINT "RND(1)"
40 FOR I=1 TO 10
50 A(I)=RND(1)
60 PRINT A(I)
70 NEXT I
RUN
RND(1)
.286546
.784621
.137119
.226544
.215274
.876763
.8574
.567958
.364675
.0333645
OK
11 - 365
RaNDom
• • • •
The generated random number varies depending on
whether a positive, 0, or negative number is
specified.
• • • •
Assigns the value generated by RND(1) to the
variable A.
• • • •
Generates a random number of the sequence
generated previously and assign it to the variable B.
• • • •
Generates a random number of a new random
number sequence and assign it to the variable C.
• • • •
A new random number is generated.
• • • •
A random number of the sequence
generated previously is generated.
• • • •
A random number of a new random
number sequence is generated.
:
'Defines an array
:
'Repeats from I = 1 to 10
:
'Generates random numbers by RND(1)
:
'Displays the result
MELSEC-Q
11 - 365

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents