DO
loops can only be used in
script files. DO
loops must be terminated with
ENDDO
. The range of the DO
loop can be any expression
resulting in a vector. The loop will execute a number of times equal to
the length of the loop range vector, with the loop variable taking on the
values of each element of the loop range vector. Nested loops are allowed.
The looping variable is created as a scalar variable.
Example
The variable j
below will be made into a scalar:
... ! DO j = x ! x must be a vector, loop will execute len(x) times with ... ! j successively taking on the value of each element of x ENDDO ! ... !
Example
... ! DO I = [2:20:4] ! the loop will execute 5 times ... ! ENDDO ! ... !
Example
... X = [1;3;5;7;9;10;12;14] DO I = X^2 ! the loop will execute LEN(X)=8 times with ... ! I taking on the values [1;9;25;49;81;100;144;196] ENDDO ...