DO
(start, stop, increment) ;
The DO function creates a row vector that contains a sequence of evenly spaced numbers.
The arguments to the DO function are as follows:
is the starting value for the sequence.
is the stopping value for the sequence.
is an increment value.
The DO function creates a row vector that contains a sequence of numbers starting with start and incrementing by increment as long as the elements are less than or equal to stop (greater than or equal to stop for a negative increment). This function is a generalization of the index creation operator (:).
The following statements show examples of using the DO function:
i = do(3, 18, 3); k = do(3, 0, -1); print i, k;
Figure 23.95: Aritmetic Sequences
i | |||||
---|---|---|---|---|---|
3 | 6 | 9 | 12 | 15 | 18 |
k | |||
---|---|---|---|
3 | 2 | 1 | 0 |