11 - 365 11 - 365
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
RND
Function
RaNDom
• Generates random numbers.
RND(<numeric expression>)
Syntax
numeric expression
• • • •
The generated random number varies depending on
whether a positive, 0, or negative number is
specified.
Examples
A=RND(1)
• • • •
Assigns the value generated by RND(1) to the
variable A.
B=RND(0)
• • • •
Generates a random number of the sequence
generated previously and assign it to the variable B.
C=RND(-1)
• • • •
Generates a random number of a new random
number sequence and assign it to the variable C.
Description
• The RND function generates a random number in the interval from 0 and up to, but not
including, 1.
• The generated random number varies depending on the value specified in <numeric
expression>.
If <numeric expression> is positive
• • • •
A new random number is generated.
If <numeric expression> is 0
• • • •
A random number of the sequence
generated previously is generated.
If <numeric expression> is negative
• • • •
A random number of a new random
number sequence is generated.
Program Example
10 ' This program generates random numbers
20 DIM A(10)
:
'Defines an array
30 PRINT "RND(1)"
40 FOR I=1 TO 10
:
'Repeats from I = 1 to 10
50 A(I)=RND(1)
:
'Generates random numbers by RND(1)
60 PRINT A(I)
:
'Displays the result
70 NEXT I
RUN
RND(1)
.286546
.784621
.137119
.226544
.215274
.876763
.8574
.567958
.364675
.0333645
OK
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...