You can create a row vector by using the index operator (:). The following statements show that you can use the index operator to count up, count down, or to create a vector of character values with numerical suffixes:
r = 1:5; s = 10:6; t = 'abc1':'abc5';
Figure 5.15: Row Vectors Created with the Index Operator
r 1 row 5 cols (numeric) |
1 | 2 | 3 | 4 | 5 |
s 1 row 5 cols (numeric) |
10 | 9 | 8 | 7 | 6 |
t 1 row 5 cols (character, size 4) |
abc1 | abc2 | abc3 | abc4 | abc5 |
To create a vector based on an increment other than 1, use the DO function. For example, if you want a vector that ranges from to by , use the following statement:
u = do(-1,1,.5);
Figure 5.16: Row Vector Created with the DO Function
u 1 row 5 cols (numeric) |
-1 | -0.5 | 0 | 0.5 | 1 |